Created
December 12, 2013 17:50
-
-
Save ColinHarrington/7932313 to your computer and use it in GitHub Desktop.
Joda-Time Period/months/age example
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
@Grab(group='joda-time', module='joda-time', version='2.3') | |
import org.joda.time.* | |
import org.joda.time.format.* | |
import java.math.* | |
LocalDate dob = new LocalDate("1950-06-15") | |
println dob | |
Period p1 = new Period(dob, new LocalDate()) | |
Period p2 = new Period(new YearMonth(dob), new YearMonth(new LocalDate())) | |
println p2 | |
Months m1 = Months.months(762) | |
println m1 | |
println new Period(m1).normalizedStandard() | |
println p2 == m1.toPeriod() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment