-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay 5.2.txt
32 lines (32 loc) · 890 Bytes
/
Day 5.2.txt
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
static String timeConversion(String s) {
if(s.substring(8).equals("PM")==true)
{
if(s.substring(0,2).equals("12")==true)
{
return s.substring(0,8);
}
else
{
int i=Integer.parseInt(s.substring(0,2));
i+=12;
String p=String.valueOf(i);
p=p+s.substring(2,8);
return p;
}
}
else
{
if(s.substring(0,2).equals("12")==true)
{
int i=Integer.parseInt(s.substring(0,2));
i-=12;
String p=String.valueOf(i);
p="0"+p+s.substring(2,8);
return p;
}
else
{
return s.substring(0,8);
}
}
}