Is 24 Hour date format in Android using java code.
private boolean is24HourFormat(Context context) {
Locale locale = Locale.getDefault();
java.text.DateFormat natural =
java.text.DateFormat.getTimeInstance(java.text.DateFormat.LONG, locale);
String value = "";
if (natural instanceof SimpleDateFormat) {
SimpleDateFormat sdf = (SimpleDateFormat) natural;
String pattern = sdf.toPattern();
if (pattern.indexOf('H') >= 0) {
value = "24";
} else {
value = "12";
}
} else {
value = "12";
}
return value.equals("24");
}
No comments:
Post a Comment