Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

test date in java

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();
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #test #date #java
ADD COMMENT
Topic
Name
8+7 =