-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime conversion.java
More file actions
41 lines (33 loc) · 954 Bytes
/
time conversion.java
File metadata and controls
41 lines (33 loc) · 954 Bytes
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
import java.io.*;
import java.util.*;
public class working{
public static void main(String args[])
{
String dt="05:05:00PM";
char ap=dt.charAt(dt.length()-2);
dt = dt.substring(0, dt.length() - 2);
if(ap =='A')
{
int hh = Integer.parseInt(dt.substring(0, 2));
if(hh==12)
{
hh=0;
}
String s=Integer.toString(hh);
if(s.length()==1)
{
s="0"+s;
}
System.out.println(s + dt.substring(2, dt.length()));
}
else
{
int hh = Integer.parseInt(dt.substring(0, 2));
if (hh != 12) hh += 12;
String s = Integer.toString(hh);
System.out.println(hh + dt.substring(2, dt.length()));
}
}
}
//output
// 17:05:00