All I really want to do is format a date using strftime("%x")
in the right order. On most platforms a call to setlocale("")
is enough. On Android I keep getting !@#$ US dates.
So, does Android not support locales?
No. setlocale()
and strftime()
does not work in Android NDK, except if en_US layout is what you want.
I get the local language from the Java part by:
pLocaleData->pLocaleLanguage = new Locale("en").getDefault().getLanguage();
And the ANSI C localeconv()
does not work in Android NDK:
struct lconv *localeconv(void);
Also the standard Unix way of getting user name, does not work in Android.
char *p = getenv("USER");
So you need to use the Java side to get the locale information.
String LocaleCountry = new Locale("en").getDefault().getCountry();
String LocaleLanguage = new Locale("en").getDefault().getLanguage();
String LocaleCurrency = new DecimalFormatSymbols().getCurrency().toString();
String LocaleShortDateTimePattern =new SimpleDateFormat().toPattern();
char LocaleDecimalSeparator = new DecimalFormatSymbols().getDecimalSeparator();
char LocaleThousandSeparator = new DecimalFormatSymbols().getGroupingSeparator();
String LocaleThousandGrouping =
String.format("%d;0", new DecimalFormat().getMaximumFractionDigits());
String LocaleNegativePrefix = new DecimalFormat().getNegativePrefix();
String LocaleNegativeSuffix =new DecimalFormat().getNegativeSuffix();
String Operator = Utils.getQwnername(context);