Created
June 5, 2020 20:39
-
-
Save JFFail/dabd6ab1334fb00bfe5e089d8072ac3c to your computer and use it in GitHub Desktop.
Get a Date object at a specified Date and Time as an ISO formatted string in UTC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TimeZone.setDefault(TimeZone.getTimeZone('UTC')) | |
Integer year = Calendar.getInstance().get(Calendar.YEAR) | |
Integer month = Calendar.getInstance().get(Calendar.MONTH) | |
def then = new GregorianCalendar(year, month, 1, 0, 0, 0).time | |
// Desired format: 2020-06-01T00:00:00.000000+00:00 | |
thenISO = then.format("yyyy-MM-dd'T'HH:mm:ss.SSSZ", TimeZone.getTimeZone("UTC")) | |
thenISOFixed = thenISO[0..thenISO.length() - 3] + ":00" | |
println thenISOFixed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment