Couldn’t translate Date to spanish with Locale(“es_ES”)

“es_ES” is a language + country. You must specify each part separately. The constructors for Locale are: Locale(String language)Construct a locale from a language code. Locale(String language, String country)Construct a locale from language, country. Locale(String language, String country, String variant)Construct a locale from language, country, variant. You want new Locale(“es”, “ES”); to get the Locale … Read more

Locale and specific date format with Moment.js

Okay. This is a little awful, but you knew it was going to be. First, you can access the actual format string for (for instance) ‘L’: var formatL = moment.localeData().longDateFormat(‘L’); Next, you can perform some surgery on it with judicious regex replacement: var formatYearlessL = formatL.replace(/Y/g,”).replace(/^\W|\W$|\W\W/,”); (Which is to say: Remove YYYY, plus the orphaned … Read more

Android: How to get string in specific locale WITHOUT changing the current locale

You can use this for API +17 @NonNull @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static String getStringByLocal(Activity context, int id, String locale) { Configuration configuration = new Configuration(context.getResources().getConfiguration()); configuration.setLocale(new Locale(locale)); return context.createConfigurationContext(configuration).getResources().getString(id); } Update (1) : How to support old versions. @NonNull public static String getStringByLocal(Activity context, int resId, String locale) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) return getStringByLocalPlus17(context, resId, … Read more

Decimal separator in NumberFormat

The helper class DecimalFomatSymbols is what you are looking for: DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(); DecimalFormatSymbols symbols = format.getDecimalFormatSymbols(); char sep=symbols.getDecimalSeparator(); To set you symbols as needed: //create a new instance DecimalFormatSymbols custom=new DecimalFormatSymbols(); custom.setDecimalSeparator(‘,’); format.setDecimalFormatSymbols(custom); EDIT: this answer is only valid for DecimalFormat, and not for NumberFormat as required in the question. Anyway, as … Read more

Error message when starting vim: “Failed to set locale category LC_NUMERIC to en_CH” (or en_BR, en_RU & LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES)

First, access your .bash_profile file by typing the following (using vim as text editor): vim ~/.bash_profile Inside the file .bash_profile, insert the following line: export LC_ALL=en_US.UTF-8 Note, however, that newer versions of macOS ship with zsh instead of bash as the default shell. If this is the case with your Mac, you will have to … Read more

Converting country codes in .NET

The RegionInfo class does know the three-letter code (in the ThreeLetterISORegionName property), but I don’t think there is a way to get RegionInfo based on this code, you would need to enumerate all regions and add them to your own dictionary, with the three-letter code as a key. However, I think the .NET Framework uses … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)