📅  最后修改于: 2022-03-11 14:56:15.259000             🧑  作者: Mango
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MM-yyyy");
String inputString1 = "23-01-1997";
String inputString2 = "27-04-1997";
try {
LocalDateTime date1 = LocalDate.parse(inputString1, dtf);
LocalDateTime date2 = LocalDate.parse(inputString2, dtf);
long daysBetween = Duration.between(date1, date2).toDays();
System.out.println ("Days: " + daysBetween);
} catch (ParseException e) {
e.printStackTrace();
}