I’ve written this code that display the current time, but my problem is it doesn’t diplay time with am or pm format, it just displays, for example, 12:00. without am or pm
java.util.Calendar thetime = java.util.Calendar.getInstance();
int h = thetime.get(java.util.Calendar.HOUR_OF_DAY);
int m = thetime.get(java.util.Calendar.MINUTE);
System.out.println("the current time is"+ h +":"+m);
Try adding:
Then add
am_pmat the end of your output.Anyway you should prefer SimpleDateFormat, try looking at it here.