c# - DateTime losing Milliseconds -
i parsing date file string , converting datetime
can compare previous date. losing milliseconds when extremely important missing lines file parsing.
example of date file extracting: 2014/11/12 10:47:23.571
m_latestprocessdate
after parseexact 12/11/2014 10:47:23
see below line of code using. ideas how around this?
datetime m_latestprocessdate = datetime.parseexact(m_currentdatestring, "yyyy/mm/dd hh:mm:ss.fff", cultureinfo.invariantculture);
codecaster explained problem, wanna add answer if let's me..
don't worry! milliseconds didn't lost. still there. sounds didn't see them when try represent m_latestprocessdate
, that's because string representation of datetime
doesn't have milliseconds part.
for example, if use datetime.tostring()
method without parameter, method uses "g"
standard format of currentculture
.
this specifier formats datetime
shortdatepattern
+ longtimepattern
. , no culture have millisecond
part on it's longtimepattern
.
for example; invariantculture
has hh:mm:ss
format doesn't represent millisecond part.
you can see milliseconds of m_latestprocessdate
like;
console.writeline(m_latestprocessdate.tostring("fff")); // prints 571
Comments
Post a Comment