Last active
January 28, 2020 20:01
-
-
Save tparton42/3057fda9c62377b3e0d8 to your computer and use it in GitHub Desktop.
Java 8: Convert JODA DateTime to Java Time.ZonedDateTime
This file contains hidden or 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
private java.time.ZonedDateTime convertJODADateTimeToJavaZonedDateTime(DateTime originDateTime, DateTimeZone originTimeZone) { | |
if (originDateTime == null || originTimeZone == zone) { | |
return null; | |
} | |
// Convert from JODA to Java 8 time | |
java.time.ZonedDateTime newDateTime = java.time.ZonedDateTime.ofInstant( | |
Instant.ofEpochMilli(originDateTime.getMillis()), java.time.ZoneId.of(zone.getID())); | |
return newDateTime; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment