In Java, I want to print just the time of day in hours and minutes and want it to correctly switch between, e.g., \"13:00\" and \"1:00 PM\" according to the locale. How do I
I have written small function which detects whether current locale uses 24 or 12 hours:
public static boolean is24HourLocale() {
String output = SimpleDateFormat.getTimeInstance(DateFormat.SHORT).format(new Date());
if (output.contains(" AM") || output.contains(" PM")) {
return false;
} else {
return true;
}
}