Skip to content

Instantly share code, notes, and snippets.

@tparton42
Last active January 28, 2020 20:01
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tparton42/3057fda9c62377b3e0d8 to your computer and use it in GitHub Desktop.
Save tparton42/3057fda9c62377b3e0d8 to your computer and use it in GitHub Desktop.
Java 8: Convert JODA DateTime to Java Time.ZonedDateTime
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