locale

java.lang.NumberFormatException while executing in France machine

半腔热情 提交于 2021-02-05 06:58:05
问题 In below code while parsing the value sometimes i am facing NumberFormat Exception in France machine. double txPower; DecimalFormat df = new DecimalFormat("##.##"); txPower = txPower + getDeltaP(); log.info("txpower value is -- "+txPower); txPower = Double.parseDouble(df.format(txPower)); protected double getDeltaP() { return isNewChannelAddition ? apaConfig.deltaPadd : apaConfig.deltaPtune; } logs: txpower value is -- -7.9 java.lang.NumberFormatException: For input string: "-7,9" 回答1: I

Is there a simple and preferred way of German number string formatting in Python?

老子叫甜甜 提交于 2021-02-05 05:44:26
问题 I am searching for the proper way of German number formatting (e.g. 1.000,1234 ) in Python under Windows OS. I tried locale.setlocale but did not succeed. Instead, I have written a function to come up with the desired output. Is there a better way? def ger_num(number, precision=3): """ returns german formatted number as string or an empty string """ if number is not None: try: my_number = "{:,f}".format(number) except ValueError: return "" decimals, fraction = my_number.split(".")[0], my

How to set data (number) format locale for specific cell using Apache POI (SXSSF)?

偶尔善良 提交于 2021-02-04 21:34:24
问题 The problem is very concrete: using Apache POI, I want to create cell (done), assign number format to it (done), and set format's locale ( stuck here ). The code looks like this: SXSSFWorkbook workbook = new SXSSFWorkbook(100); Sheet sheet = workbook.createSheet(); Row row = sheet.createRow(1); Cell cell = row.createCell(0); CellStyle cellStyle = workbook.createCellStyle(); cellStyle.setDataFormat(8); //currency with thousands separator and two decimal places after period cell.setCellValue

Spring LocaleContextHolder not correctly set

给你一囗甜甜゛ 提交于 2021-01-29 17:13:13
问题 I'm having some issues with Spring LocaleContextHolder . I have the following code: public void sendPasswordRecoverySmsAsync(String phone) { CompletableFuture.runAsync(() -> { sendPasswordRecoverySmsSync(phone); }); } public void sendPasswordRecoverySmsSync(String phone) { User user = userDao.findByPhone(phone, User.class).orElseThrow(() -> new UserNotFoundException(phone)); log.info("User found, recovering password"); user.setUpdateTime(LocalDateTime.now()); userDao.save(user); int otp =

cs-Cz locale and JavaScript new Date Constructor doesn't allow for shorthand date

喜你入骨 提交于 2021-01-29 12:38:21
问题 So I'm trying to follow the docs here on MDN regarding the date options for formatting https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat For the cs-cz locale, I want the month to be in "short" hand form when writing a date such as 19. 12. 2012 instead of 19. pro 201 This code works for locales such as en-us or it-it (italy) and others. var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0, 200)); var options = { month: 'short', day: 'numeric',

Change Language for Xamarin Android App using Resources

落爺英雄遲暮 提交于 2021-01-29 05:15:23
问题 I have a requirement to change language of App on selection of radio buttons. App already has localization implemented using Android Resources. I have tried below solutions in different combinations from Activity as well as normal class, but nothing worked so far: CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(lang); // lang => en-US or nl-BE System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(lang); var locale = new Java.Util.Locale(lang); Java.Util.Locale

How to use PHP Locale functions

我们两清 提交于 2021-01-28 05:51:39
问题 I'm running PHP on windows vista . So, I'm trying to get to know how locale functions work. I started with setlocale(LC_ALL, $locale) and localeconv() At first it worked with CLDR locale IDs(I think.., Just started learning PHP locales) like "en_US", "en_UK", etc, resulting as demonstrated in the PHP documentation examples. But now setlocale() and localeconv() only works with $locale values like "English_United Kingdom.1252" and "English_United States.1252" which I believe is windows based

Does the Android NDK support locales?

拥有回忆 提交于 2021-01-28 05:09:39
问题 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? 回答1: 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

Changing Locale at runtime not effecting fragments

老子叫甜甜 提交于 2021-01-28 03:05:47
问题 When user changes language i execute following code,it works fine for the present fragment in the activity, but if i go to other fragment, it partially updates the language, some strings gets updated and shows old language, and most importantly the date does not changes in inner fragments,and other activities. I tested this in nougat, marshmallow and oreo, and its happening in all of OS. When user changes the language i execute following. LocaleHelper.setLocale(getApplicationContext(),

Locale.getDefault() is outdated on some Android devices

你。 提交于 2021-01-28 02:21:59
问题 I have a broadcast receiver in my app that gets called when the device's locale changes. There is a bug in my app on a few devices, specifically the Nexus 5x and Galaxy S8+ (and very likely others) where Locale.getDefault() returns the stale/previous value. The localized strings are displaying correctly for the new language, but inside the application, our locale is outdated. Any ideas? ex: 1) Device is in English -> App locale tells us we are in English. 2) Background the app and change the