In objective c, what is the right date format for "2011-05-10T14:30:00 0000"?
I know for "2011-05-10T14:30:00-0000", this "[someDateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ssZZZ"]; " works. But just couldn't figure out how to configure the format so it know开发者_StackOverflow中文版s that the time zone has space sign before it instead of "-" sign? Thanks!
1..3 capital Z pattern denotes a RFC 822 time zone. RFC 822 time zones represent the offset from GMT (or UTC), which has the following format. From the RFC 822 standard:
zone = "UT" / "GMT" ; Universal Time
; North American : UT
/ "EST" / "EDT" ; Eastern: - 5/ - 4
/ "CST" / "CDT" ; Central: - 6/ - 5
/ "MST" / "MDT" ; Mountain: - 7/ - 6
/ "PST" / "PDT" ; Pacific: - 8/ - 7
/ 1ALPHA ; Military: Z = UT;
; A:-1; (J not used)
; M:-12; N:+1; Y:+12
/ ( ("+" / "-") 4DIGIT ) ; Local differential
; hours+min. (HHMM)
As you can read towards the end it expects a sign, either '+' or '-'. So, in your case, does the lack of sign implies a positive '+' or a negative '-' offset?
You could manually pre-parse your string adding the missing sign to conform to the specification.
Simply replace '-' with ' ' in the date format syntax (there is a space inside the single quotes)
精彩评论