c# - 无法在 C# 中解析 Oracle 时间戳

标签 c# asp.net regex oracle odp.net

我有 Oracle 的时间戳:

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

我无法将其解析为系统日期时间对象。我用过:

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);
}

还是报错。它在 m 之后工作 7 f,但不会超过那个。我尝试使用 Parse,尝试 ParseExact - 有什么办法吗?

最佳答案

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

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);

虽然不是很漂亮。

关于c# - 无法在 C# 中解析 Oracle 时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24990166/

相关文章:

c# - 在 TestResults 的 deploymentFolder 的 "Out"文件夹中从 UnitTest 输出,在 Visual Studio 中使用 MSTest

c# - 从窗口获取唯一标识

c# - .NET 内存大小

c# - 在C#Web表单上的每个请求上运行的事件

asp.net - 防止将 aspnet_client 文件夹添加到 .NET 站点

c# - 如何在 asp.net 中使用 C# 代码将参数传递给 JavaScript 函数?

c# - 我应该使用线程还是任务 - 多客户端模拟

javascript - 电子邮件正则表达式与 Ruby 和 Javascript 兼容

当脚本不是页面的一部分时,JavaScript "document is not defined"错误

python - 正则表达式在 Pythex 上运行良好,但在 Python 上运行不佳