Skip to content

Commit

Permalink
1360
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangshanmeta committed Oct 7, 2024
1 parent 8e830cc commit 70be23f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/1360.number-of-days-between-two-dates.1274/solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

class Solution {
public int daysBetweenDates(String date1, String date2) {
return Math.abs((int) ChronoUnit.DAYS.between(
toLocalDate(date1), toLocalDate(date2)));
}

private LocalDate toLocalDate(String date) {
return LocalDate.parse(date);
}
}

0 comments on commit 70be23f

Please sign in to comment.