Created
November 29, 2017 14:02
-
-
Save setanjan123/85c32c056f753cd4ef428646644c7709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class Solution { | |
static String timeConversion(String s) { | |
String time[]=s.split(":"); | |
if(time[2].contains("PM")) | |
{ if(Integer.parseInt(time[0])!=12) | |
{ int hours=Integer.parseInt(time[0])+12; | |
time[0]=Integer.toString(hours); | |
} | |
} | |
else if(time[2].contains("AM")) | |
{ | |
if(Integer.parseInt(time[0])==12) | |
time[0]="00"; | |
} | |
String str = String.join(":", time); | |
String str2=str.substring(0,8); | |
return str2; | |
} | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
String s = in.next(); | |
String result = timeConversion(s); | |
System.out.println(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment