Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ISO8601 Date
import java.text.DateFormat
import java.text.SimpleDateFormat
TimeZone tz = TimeZone.getTimeZone("Europe/Berlin") // Change the timezone
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmX") // X is the timezone in ISO8601
df.setTimeZone(tz)
String iso8601 = df.format(new Date())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment