First, I’m going to draw your attention to Unicode Technical Standard #35 Part 4 Dates. This is the definitive specification for how date format strings are intended to behave.
Specifically, look at the Date Field Symbol Table. The time zone specifier you’re using,
Zzzz
, is not listed there at all. I’m going to presume that, by starting with an uppercase
Z, your goal was to get
ZZZZ
. In that case, compare the example listed there,
GMT-8:00
, against your example,
GMT+0530
. Note the absence of a colon. If you change your example to use
ZZZZ
and include a colon, the string parses as you expect.
Where are you getting this string from? It seems like the folks generating it should be including that colon. Alternatively, if you have to deal with the string as is, you could use a format string that contains the literal
GMT
and the
ZZZ
token, that is,
E MMM d yyyy HH:mm:ss 'GMT'ZZZ
.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"