Here you can find the source of canonicalTimeString(ZonedDateTime time)
public static String canonicalTimeString(ZonedDateTime time)
//package com.java2s; //License from project: Apache License import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; public class Main { private static DateTimeFormatter canonicalFormatter = DateTimeFormatter .ofPattern("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"); /**/*from w ww . ja v a2 s.co m*/ * ISO8601 can map the same date and time to many different string * representations. This method tries to settle on a sane default (which * happens to match Python's default, albeit more because that's convenient * than because Python's default is OMG AMAZING). */ public static String canonicalTimeString(ZonedDateTime time) { // Target format is "2013-05-27T23:58:20+00:00". ZonedDateTime asUTC = time.withZoneSameInstant(ZoneOffset.UTC); return asUTC.format(canonicalFormatter); } }