import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.Date;
public class DateChal {
public static void main(String[] args) {
// TODO Auto-generated method stub
LocalDate start=LocalDate.parse("2018-10-25");
LocalDate end=LocalDate.parse("2019-10-25");
Period p=Period.between(start, end);
System.out.println("Number of days "+p.getDays());
}
}
o/p:Number of days 0 How to resolve the issue? Please explain what is wrong also?
最佳答案
结果期间包含1年0月0日。您只需打印天数,即 0。
关于Java:为什么 java.LocalDate 格式在 2018-10-25 到 2019-10-25 之间给出 0 天?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52759093/