FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode-algorithms/src/ReformatDate.java at master · anishLearnsToCode/leetcode-algorithms · GitHub
anishLearnsToCode
/
leetcode-algorithms
Public
Notifications
You must be signed in to change notification settings
Fork
17
Star
98
Code
Issues
0
Pull requests
0
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode-algorithms
/
src
/
ReformatDate.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (33 loc) · 1 KB
Breadcrumbs
leetcode-algorithms
/
src
/
ReformatDate.java
Copy path
File metadata and controls
35 lines (33 loc) · 1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
public
class
ReformatDate
{
public
String
reformatDate
(
String
date
) {
final
String
[]
parts
=
date
.
split
(
" "
);
return
new
StringBuilder
(
parts
[
2
])
.
append
(
'-'
)
.
append
(
getMonth
(
parts
[
1
]))
.
append
(
'-'
)
.
append
(
getDay
(
parts
[
0
]))
.
toString
();
}
private
String
getMonth
(
String
month
) {
return
switch
(
month
) {
case
"Jan"
->
"01"
;
case
"Feb"
->
"02"
;
case
"Mar"
->
"03"
;
case
"Apr"
->
"04"
;
case
"May"
->
"05"
;
case
"Jun"
->
"06"
;
case
"Jul"
->
"07"
;
case
"Aug"
->
"08"
;
case
"Sep"
->
"09"
;
case
"Oct"
->
"10"
;
case
"Nov"
->
"11"
;
case
"Dec"
->
"12"
;
default
->
""
;
};
}
private
String
getDay
(
String
string
) {
if
(
string
.
length
() ==
3
) {
return
'0'
+
string
.
substring
(
0
,
1
);
}
return
string
.
substring
(
0
,
2
);
}
}
Back
|
FazBrowse Home
|
New Git URL