C#如何解析日期的字符串在任意指定的Oracle日期格式? [英] C# How to parse a string of date in an arbitrary specified Oracle date format?

查看:195
本文介绍了C#如何解析日期的字符串在任意指定的Oracle日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何解析日期的字符串在C#中任意指定的Oracle日期格式?

How to parse a string of date in an arbitrary specified Oracle date format in C#?

所以... oracle的格式字符串是从C#有点不同日期时间格式的字符串,所以我不能使用该格式字符串作为解析的参数。
我使用Devart /岩心研究,但他们的OracleDate.Parse似乎是很奇怪的,而不是为我工作。我怎样才能正确分析吗?
我一定要打电话查询的分贝与TO_DATE / TO_CHAR只是为了获得一个转换? ?或者说,我要每个Oracle格式字符串元素成C#格式字符串元素映射

So... the oracle format string is a bit different from the C# datetime format string, so I can't use that format-string as an argument for the parse. I am using Devart/CoreLab but their OracleDate.Parse seems to be really strange and not working for me. How can I parse it correctly? Do I have to call a query to the db with a TO_DATE/TO_CHAR just to get a conversion? Or that I have to map each oracle format string element into a C# format string element?

编辑:与甲骨文和C#格式字符串是不同的,如MON代替MMM的...

edit: And the format string of Oracle and C# are different, such as MON instead of MMM...

EDIT2:更多的澄清:
基本上我会字符串是甲骨文最新功能于字符串,如2008年10月85,而我也能得到这些日期字符串以下,如DD-MON-YY神谕格式模式,DD-MON-RR,YYYY / RM / DD ...等。

edit2: more clarification: Basically I would have strings that are oracle-date-in-string, e.g. "08-OCT-85", and I am also able to get the oracle format pattern that these date string is following, such as "DD-MON-YY", "DD-MON-RR", "YYYY/RM/DD"... etc

我希望能够把它解析为一个C#的DateTime正确,这样我可以将它们设置为参数(预计C#日期时间),以及问题是这些预言 - 日期 - 格式图案是不一样的C#的日期时间解析的格式图案。

I would like to be able to parse them into a C# DateTime properly so that I can set them to Parameter (which expects C# DateTime), and the problem is these oracle-date-format-pattern is not the same as the C# DateTime-parse-format-pattern.

我怀疑某个地方可能存在某种功能,可以做这样的事情
DateTime的DT = ParseDatestringWithSpecifiedOracleDatePatternIntoCSharpDateTime(08-OCT-85,DD-MON -YY);对
,但我还不能找到它:(

I suspect somewhere out there might exist some function that can do something like DateTime dt = ParseDatestringWithSpecifiedOracleDatePatternIntoCSharpDateTime("08-OCT-85", "DD-MON-YY); right? But I can't find it yet :(

推荐答案

DateTime.TryParseExact 让你传递一个格式字符串精确定义格式(或格式依次尝试一个数组)。

DateTime.TryParseExact allows you do pass a format string to exactly define the format (or an array of formats to try in turn).

这篇关于C#如何解析日期的字符串在任意指定的Oracle日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆