无法分析甲骨文时间戳在C# [英] Unable to parse Oracle timestamp in C#

查看:234
本文介绍了无法分析甲骨文时间戳在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有甲骨文的时间戳:

string timestamp = "23-JUN-14 09.39.04.000000000 AM";

我不能把它解析为系统日期时间对象。我用:

I am not able to parse it into system date time object. I used:

CultureInfo provider = CultureInfo.InvariantCulture;
                String format = "yy-MMM-dd hh:mm:ss:fffffff";
                string timestamp = "10-DEC-07 10.32.47.797201123 AM";
                {
                    var date = DateTime.ParseExact(timestamp, format, provider);
                    DateTime dateTime = DateTime.ParseExact(timestamp.ToString(), "dd-MMM-y HH:mm:ss", CultureInfo.InvariantCulture);
}

它仍然是传递错误。这是工作后米7 F,但不多说。我曾经尝试解析,试试 ParseExact - ?有什么办法

It is still passing error. It is working 7 f after m but not more than that. I used try Parse, try ParseExact - is there any way?

推荐答案

根据 http://stackoverflow.com/a/23198962 / 328864 ,没有办法跳过一个确切的模式的部分,所以我想你可以做这样的事情:

According to http://stackoverflow.com/a/23198962/328864, there is no way to skip parts of an exact pattern, so i guess you could do something like this:

CultureInfo provider = CultureInfo.InvariantCulture;
string timestamp = "10-DEC-07 10.32.47.797201123 AM";
String format = String.Format("yy-MMM-dd hh.mm.ss.fffffff{0} tt", timestamp.Substring(26,2));

DateTime date = DateTime.ParseExact(timestamp, format, provider);
Console.WriteLine(date);

不是很pretty虽然。

Not very pretty though.

这篇关于无法分析甲骨文时间戳在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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