68 758
Assignments Done
Successfully Done
In January 2019

Answer to Question #64580 in Java | JSP | JSF for Sherlynn

Question #64580
Write a JAVA program that asks the user to enter time in 24hour format. Convert it into 12-hour format. Repeat the program by asking whether the user wants to continue (yes continue, no: stop the program) or not
Expert's answer
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Format {

public static void main(String[] args) {
try {
Scanner sc = new Scanner(System.in);
String contin = "";
System.out.println("Time in 24 hour format(example 23:12):");
String _24HourTime = sc.nextLine();
SimpleDateFormat _24HourSDF = new SimpleDateFormat("HH:mm");
SimpleDateFormat _12HourSDF = new SimpleDateFormat("hh:mm a");
Date _24HourDt = _24HourSDF.parse(_24HourTime);
System.out.println("Entet your answer(yes continue, no: stop the program):");
contin = sc.nextLine();
} catch (Exception e) {


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions