java - Time between Dates using LocalDate and Period -
if do:
public static void main(string[] args) { localdate d1 = localdate.of(2015, month.march, 12); localdate d2 = localdate.of(2015, month.april, 13); system.out.println(d1.until(d2).getdays()); // prints 11 localdate d3 = localdate.of(2015, month.april, 25); // prints 23.
both of incorrect. second output makes sense there 1 month , 23 days between them.
how total number of days between?
i want first output 32 days , second 44 days (the total number of days between 2 dates).
what doing wrong? don't see totaldays()
method.
you should not use period (which has year , month components) if interested in days. 1 solution question is:
system.out.println(days.between(d1, d2)); //32
or alternatively:
system.out.println(d1.until(d2, days)); //32
note: i'm using import static java.time.temporal.chronounit.days;
Comments
Post a Comment