Last active
October 28, 2019 18:37
-
-
Save nbenns/29ee5217a3881bb1072b1008c4c88104 to your computer and use it in GitHub Desktop.
Using ZonedDateTime properly
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
def fromISOString(d: String): ZonedDateTime = | |
ZonedDateTime.parse(d, DateTimeFormatter.ISO_OFFSET_DATE_TIME).withZoneSameInstant(ZoneOffset.UTC) | |
def toISOString(d: ZonedDateTime) = d.withZoneSameInstant(ZoneOffset.UTC).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME) | |
// parsing a "date only" | |
LocalDate.parse(str).atStartOfDay(ZoneOffset.UTC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment