Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.time.LocalDate;
- import java.time.Period;
- public class Ch {
- public static void main(String[] args) {
- int a = 20200502; LocalDate la = lo(a); System.out.println(la);
- int b = 20190401; LocalDate lb = lo(b); System.out.println(lb);
- Period p = Period.between(lb, la);
- System.out.println(p);
- System.out.println(p.getYears());
- System.out.println(p.getMonths());
- System.out.println(p.getDays());
- System.out.println(la.minusYears(1).minusMonths(1).minusDays(1));
- System.out.println(la.minus(Period.parse("P1Y1M1D")));
- }
- private static LocalDate lo(int a) {
- return LocalDate.of(a / 10000, (a % 10000) / 100, a % 100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement