Unable to parse Oracle timestamp in C#

后端 未结 3 1939
执念已碎
执念已碎 2021-01-21 08:49

I have timestamp of Oracle:

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

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

3条回答
  •  面向向阳花
    2021-01-21 09:20

    According to https://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);
    

    Not very pretty though.

提交回复
热议问题