Last active
August 29, 2015 14:25
-
-
Save Budincsevity/ffd25f4ad99d03eb8dc5 to your computer and use it in GitHub Desktop.
Migrating from JodaTime Period to ThreeTen
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
//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