7 Replies Latest reply on Mar 8, 2017 2:02 AM by mdelson

    decimal replaces with comma (34.00 is replace 34,00)

    mdelson

      We are testing our application with wildfly 10/ Java8

       

      we have set

       

      -Duser.language=en to the JAVA_OPTS

       

      and in standalone.xml we have set the system-properties as below

       

      <system-properties>

      <property name="org.jboss.dashboard.LocaleManager.installedLocaleIds" value="en,es,de,fr,ja,pt"/>

      <property name="org.jboss.dashboard.LocaleManager.defaultLocaleId" value="en"/>

      </system-properties>

       

      But still we see that in the number format (dot) is replacing with  (comma)

      Exception in miscInvoice service::java.lang.NumberFormatException: For input string: "197942,00"

       

      all works fine when we restart the wildfly instance and after 3-4 hrs this issue is seen. Any idea what would be triggering this issue?

        • 1. Re: decimal replaces with comma (34.00 is replace 34,00)
          jaikiran

          Which exact version of WildFly? Please post the entire exception stacktrace. Also, how and where are you providing that numeric value?

          • 2. Re: decimal replaces with comma (34.00 is replace 34,00)
            ctomc

            Micheal Delson Nadar wrote:

            <system-properties>

            <property name="org.jboss.dashboard.LocaleManager.installedLocaleIds" value="en,es,de,fr,ja,pt"/>

            <property name="org.jboss.dashboard.LocaleManager.defaultLocaleId" value="en"/>

            </system-properties>

             

            Why did you set this system properties? They do noting for WildFly at all.

            • 3. Re: decimal replaces with comma (34.00 is replace 34,00)
              mdelson

              Thanks for the reply. I thought may be setting the system locale should help which actually didn't.

               

              WildFly Version : wildfly-10.0.0.Final

              Java Version : jdk1.8.0_72

               

              we have only NumberFormatException seen as posted in initial post. There is no additional exception seen in server log.

               

               

              we are using below code to change the number format

               

              DecimalFormat amtFormat = new DecimalFormat("0.00");

              ......

              ...

              double availableCredit = result.getDouble("AVAILABLE_CREDIT");

              form.setAvailableCredit(amtFormat.format(availableCredit));

              • 4. Re: decimal replaces with comma (34.00 is replace 34,00)
                pferraro

                The DecimalFormat constructor used above will use a locale specific DecimalFormatSymbols, specifically, the instance returned via: DecimalFormatSymbols (Java Platform SE 8 )

                 

                More details regarding locales and how to set the default locale for the JVM can be found here:

                Internationalization: Understanding Locale in the Java Platform

                • 5. Re: decimal replaces with comma (34.00 is replace 34,00)
                  mdelson

                  Will follow the link and confirm.Thank you.

                  • 6. Re: decimal replaces with comma (34.00 is replace 34,00)
                    anil_ch_jboss

                    Hi Micheal,

                    We are facing a similar issue, which works for 2-3 hrs after restart and later get the same decimal format error. Was your issue resolved and what was the change done?

                    • 7. Re: decimal replaces with comma (34.00 is replace 34,00)
                      mdelson

                      we have resolved by handling the same at the code level

                       

                      =====================static method===========================

                      import java.text.DecimalFormat;

                      import java.text.NumberFormat;

                      import java.util.Locale;

                       

                       

                      public class CustomNumberFormat

                      {

                        public static DecimalFormat decFormat = null;

                        static

                        {

                        decFormat = (DecimalFormat) NumberFormat.getNumberInstance(new Locale("en", "UK"));

                        }

                       

                      public static String twoDecimalFormat (double inValue)

                        {

                        String outValue = null;

                        try

                        {

                        decFormat.applyPattern("#0.00");

                        outValue = decFormat.format (inValue);

                        } catch (Exception e) {

                        }

                         return outValue;

                        }

                       

                      public static String oneDecimalFormat (String inValue)

                        {

                        String outValue = null;

                        try

                        {

                        double parseValue = Double.parseDouble (inValue);

                        decFormat.applyPattern("#0.0");

                        outValue = decFormat.format (parseValue);

                        } catch (Exception e) {

                        }

                      return outValue;

                        }

                      ================================================

                       

                       

                      call the same where ever needed as below

                       

                       

                      CustomNumberFormat.twoDecimalFormat(Double.parseDouble(resultTableData.get(i).get("MY_AMOUNT").toString()))