JakeWharton / ThreeTenABP

An adaptation of the JSR-310 backport for Android.
Apache License 2.0
3.55k stars 133 forks source link

Inaccurate birthday. #89

Closed ralphgabrielle closed 6 years ago

ralphgabrielle commented 6 years ago

As of today, its November 12, 2018.

I set a birthdate of November 13, 2000 which should be 17 years old (will be 18 tomorrow), but Period.between returns 18.

Is it just basing on number of years not the actual days (including leap years.)

Thanks, I would appreciate any help or suggestion and/or any mistake on my end.

Currently this is my implementation just same with what we have on official Java8 implementation.

        org.threeten.bp.LocalDate birthDate = org.threeten.bp.LocalDate.of(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
        org.threeten.bp.LocalDate today = org.threeten.bp.LocalDate.now();
        org.threeten.bp.Period between = org.threeten.bp.Period.between(birthDate, today);
        int ageInYears = between.getYears();

Thanks, Ralph

JakeWharton commented 6 years ago

This library is just a repackaging of the timezone database for Android. All issues with the DB, API, or implementation should be filed at https://github.com/ThreeTen/threetenbp