0

What is lacking with my military time code?

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); int ntime; String time = input.nextLine(); String [] arr=time.split(":"); if(arr[1].charAt(3)=='P'){ ntime=Integer.parseInt(arr[0])+12; } else ntime=Integer.parseInt(arr[0]); String ttime[]=arr[1].split(" "); System.out.print(ntime+":"+ttime[0]); } }

10th Jan 2020, 11:03 PM
Chester Jeff Ancheta
4 Respuestas
+ 2
Does your version take care of cases like 01:23?
10th Jan 2020, 11:11 PM
HonFu
HonFu - avatar
+ 1
The output has to look for example like this: 01:23.
10th Jan 2020, 11:19 PM
HonFu
HonFu - avatar
+ 1
I get it now thanks bro
10th Jan 2020, 11:19 PM
Chester Jeff Ancheta
0
You mean 1:23 PM or AM? or just 1:23?
10th Jan 2020, 11:18 PM
Chester Jeff Ancheta