- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1507.java
63 lines (60 loc) · 1.82 KB
/
_1507.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
packagecom.fishercoder.solutions.secondthousand;
publicclass_1507 {
publicstaticclassSolution1 {
publicStringreformatDate(Stringdate) {
String[] dates = date.split(" ");
returndates[2] + "-" + getMonth(dates[1]) + "-" + getDay(dates[0]);
}
privateStringgetDay(Stringday) {
StringformatedDay = day.substring(0, day.length() - 2);
if (formatedDay.length() == 1) {
return"0" + formatedDay;
}
returnformatedDay;
}
privateStringgetMonth(Stringmonth) {
Stringresult = "";
switch (month) {
case"Jan":
result = "01";
break;
case"Feb":
result = "02";
break;
case"Mar":
result = "03";
break;
case"Apr":
result = "04";
break;
case"May":
result = "05";
break;
case"Jun":
result = "06";
break;
case"Jul":
result = "07";
break;
case"Aug":
result = "08";
break;
case"Sep":
result = "09";
break;
case"Oct":
result = "10";
break;
case"Nov":
result = "11";
break;
case"Dec":
result = "12";
break;
default:
result = "";
}
returnresult;
}
}
}