-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimeconvertjava.txt
More file actions
39 lines (38 loc) · 895 Bytes
/
timeconvertjava.txt
File metadata and controls
39 lines (38 loc) · 895 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
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
int i;
Scanner obj = new Scanner(System.in);
String s = obj.nextLine();
char[] c = s.toCharArray();
int x = 10*Character.getNumericValue(c[0])+Character.getNumericValue(c[1]);
if(c[8]=='A'){
if(c[0]=='1' && c[1]=='2'){
c[0]=c[1]='0';
for(i=0;i<8;i++)
System.out.print(c[i]);
}
else{
for(i=0;i<8;i++)
System.out.print(c[i]);
}
}
if(c[8]=='P'){
if(c[0]=='1' && c[1]=='2'){
for(i=0;i<8;i++)
System.out.print(c[i]);
}
else{
x+=12;
int v=x%10;
c[1]=Character.forDigit(v, 10);
x/=10;
c[0]=Character.forDigit(x, 10);
for(i=0;i<8;i++)
System.out.print(c[i]);
}
}
}
}