Skip to content

Instantly share code, notes, and snippets.

@Budincsevity
Last active August 29, 2015 14:25
Show Gist options
  • Save Budincsevity/ffd25f4ad99d03eb8dc5 to your computer and use it in GitHub Desktop.
Save Budincsevity/ffd25f4ad99d03eb8dc5 to your computer and use it in GitHub Desktop.
Migrating from JodaTime Period to ThreeTen
//JodaTime
Interval interval = new Interval(time, new Date().getTime());
Period period = interval.toPeriod();
int minutes = period.getMinutes();
int hours = period.getHours();
//ThreeTen
Instant firstInstant= Instant.ofEpochMilli(time);
Instant secondInstant = Instant.ofEpochMilli(new Date().getTime());
Duration between = Duration.between(firstInstant, secondInstant);
long minutes = between.toMinutes();
long hours = between.toHours();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment