Does a UTC date string require a ā€œZā€ format specifier, even if this string contains a time offset?

For example,

Date d = "2012-08-20T15:00:00-07:00"; 

d here is the UTC time with a time offset = 07:00 . Is this Z required for this 2012-08-20T15:00:00-07:00Z ? Is it correct?

If I take this string using Z and pase using the Date.parse() method in JavaScript, it throws an error. Not sure what is wrong!

+7
source share
2 answers

No, you should not include a ā€œZā€ with a time zone offset.

From rfc3339 :

  ZA suffix which, when applied to a time, denotes a UTC offset of 00:00; often spoken "Zulu" from the ICAO phonetic alphabet representation of the letter "Z". 

"Z" is a zero time offset, so turning it on with an explicit offset (especially non-zero) does not make sense.

+11
source

Quote W3C note about date and time formats :

YYYY-MM-DDThh: mm: ss.sTZD (e.g. 1997-07-16T19: 20: 30.45 + 01: 00)

Where:

[...]

 TZD = time zone designator (Z or +hh:mm or -hh:mm) 

Pay attention to the word above. You either specify the time zone offset, or Z for Zulu (no offset).

+6
source

All Articles