How do I find out whether a locale uses 12 or 24 hour time in Java? -


In Java, I want to print time of the day in just hours and minutes and want to correctly switch between it Like, "13:00" and "1:00 AM" according to locale, how do I do this?

Locale does not explicitly specify whether the 12 or 24 hour format are preferred. Instead, locale specific date formats are controlled by the locale defining the formats directly.

  • If you want to use only "locale favorites" time format, then only use three static methods, and whatever dateFormat is used.

  • If you have an SimpleDateFormat example, you (if you were prepared to make a significant amount of coding) call the resulting pattern Make and parse whether it uses a date of 12 or 24 hours ... or you can also use the "other" form to convert the pattern and then call to change the format Are there.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -