Browse - Programming Tips - Java: format date/time as ISO 8601 with 'T'

Date: 2019jun20
Language: Java
Keywords: GMT, UTC

Q.  Java: format date/time as ISO 8601 with 'T'

A.

String iso8601Date(final Date date) { SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US); fmt.setTimeZone(TimeZone.getTimeZone("UTC")); return fmt.format(date); }