- #1
major_maths
- 30
- 0
I'm trying to write a program that converts military time to civilian time (24-hour to the standard 12-hour) but I'm having trouble with changing the delimiter to ":". I've tried re-working the code every way I can think of and it still won't work properly.
Code:
import java.util.Scanner;
public class Program4
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
keyboard.useDelimiter(":");
String theHour, theMin;
System.out.println("Enter time in 24-hour notation.");
theHour=keyboard.next();
theMin=keyboard.next();
System.out.println("The time is "+theHour+":"+theMin);
}
}