- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1360.java
27 lines (25 loc) · 1.08 KB
/
_1360.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
packagecom.fishercoder.solutions.secondthousand;
publicclass_1360 {
publicstaticclassSolution1 {
publicintdaysBetweenDates(Stringdate1, Stringdate2) {
String[] strings1 = date1.split("-");
String[] strings2 = date2.split("-");
returnMath.abs(
julianDay(
Integer.parseInt(strings1[0]),
Integer.parseInt(strings1[1]),
Integer.parseInt(strings1[2]))
- julianDay(
Integer.parseInt(strings2[0]),
Integer.parseInt(strings2[1]),
Integer.parseInt(strings2[2])));
}
publicintjulianDay(intyear, intmonth, intday) {
inta = (14 - month) / 12;
inty = year + 4800 - a;
intm = month + 12 * a - 3;
intjdn = day + (153 * m + 2) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 32045;
returnjdn;
}
}
}