Java

No description

fork
loading
Files
  • Main.java
  • jdt.ls-java-project
Main.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
class Main {
  static String timeConversion(String s) {
        String hour = s.substring(0, 2);
        String mid = s.substring(2, 8);
        String pm_am = s.substring(8, 10);

        System.out.println(pm_am);

        if (pm_am == "AM") {
            if (hour == "12") {
                return "00" + mid;
            }
            return hour + mid;
        } else {
            if (hour == "12") {
                return "12" + mid;
            }
            return (Integer.parseInt(hour) + 12) + mid;
        }
    }

    public static void main(String[] args) {
        System.out.println(timeConversion("07:03:01AM"));
    }
}