I want to create a NSDateFormatter which should parse such date "2014-05-13 23: 31: 41.374577." Therefore:
NSDateFormatter * formatter = [[NSDateFormatter alloc] init]; Formatter.dateFormat = @ "yyyy-MM-dd HH: mm: ss.SSSSSS"; NSString * dateString = @ "2014-05-13 23: 31: 41.374577"; NSDT * date = [format dateofrostring: datestring]; NSString * anotherDateString = [format string string: date];
However, anotherDateString
is 2014-05-13 23: 31: 41.374000
. Why does it feel that milliseconds are reduced?
It seems that NSDateFormatter
millisecond resolution for the following reasons:
-
CFDateFormatterCreateDateFromString
a breakpoint is set, can see that this functiondateFromString:
:(Lldb) bt * thread # 1: TID = 0x26d03f, 0x018f47d0 CoreFoundation`CFDateFormatterCreateDateFromString, queue = 'com.apple.main thread', stop reason = breakpoint 3.1 frame # 0: 0x018f47d0 core framework `CFDATformatcracket frame string frame # 1: 0x0116e0ea Foundation'g Magistrate object value + 248 Frame # 2: 0x0116 DFC 7 Foundation - [Ansdiattformment the object value: for string: Error Description:] + 206 Frame # 3: 0x0116879 F Foundation [Ansdiattformr Dinankfremstring] 71 * Frame # 4: 0x00002d56 foo `main (argc = 1, argv = 0xbfffee54) + 182 on main.mm:25
-
CFDateFormat TerCreateDateFromString () is
Which is open source. One can see that all the almanac calculations are made. -
It is not that
calendar
usesUDate
, which states that a millisecond resolution:/ ** * & lt; Code & gt; Calendar & lt; / Code & gt; A & lt; Code & gt; Eudit & lt; / Code & gt; There is an abstract base class to change between. A set of objects and such as * lt integers; YEAR & lt; Code & gt / Code & gt ;, & lt; Code & gt; Month & lt; / Code & gt ;, & lt; Code & gt; Day & lt; / Code & gt ;, & lt; Code & gt; This hour & lt; / Code & gt ;, * and so on. (A & LT; code See & gt; UDate & lt; / code & gt; object UDate For information about the * time with millisecond precision represents a specific instant & lt * ;. code & gt; UDate & lt; / code & gt; class) * ...
No comments:
Post a Comment