➽ Problem:-
https://www.hackerrank.com/challenges/time-conversion/problem
➽ Solution:-
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
String str = in.nextLine();
DateFormat inFormat = new
SimpleDateFormat("hh:mm:ssaa");
DateFormat outFormat = new
SimpleDateFormat("HH:mm:ss");
Date date = null;
try
{
date = inFormat.parse(str);
}
catch(ParseException c )
{
c.printStackTrace();
}
if(date != null)
{
String myDate =
outFormat.format(date);
System.out.println(myDate);
}
}
}
0 Comments
Please do not enter any spam link in the comment section.