简体   繁体   中英

Is this date in Zulu (UTC) timezone?

I have a date string as below.

I think this implies it is in UTC timezone.

Is that correct?

2016-10-30T15:27:02.000Z

Yes. According to joda , the first millisecond in UTC can be represented in this format: 1970-01-01T00:00:00Z

You correctly guessed it, thats UTC Date and Time.

ISO 8601

Which is October 30th, 2016, at 3:27 pm (+2 seconds) in Greenwich Mean Time.

For further reference you can check

ISO 8601

StackExchange

Yes, you can verify it by parsing a java.time.ZonedDateTime from the String and print the offset information of it:

public static void main(String[] args) {
    String utcDateTime = "2016-10-30T15:27:02.000Z";
    ZonedDateTime zdt = ZonedDateTime.parse(utcDateTime);
    System.out.println(zdt.format(DateTimeFormatter
                        .ofPattern("uuuu-MM-dd HH:mm:ss zzz '==>' xxx '=' O")));
}

This outputs

2016-10-30 15:27:02 Z ==> +00:00 = GMT

Note: This output pattern contains redundant information for verification, see the pattern letters in the JavaDocs of java.time.format.DateTimeFormatter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM