Uploaded image for project: 'Commons CLI'
  1. Commons CLI
  2. CLI-226

createNumber() in TypeHandler cannot work with some Locale

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2
    • None
    • None

    Description

      The createNumber() method in the TypeHandler class expects the decimal separator to be a dot ('.'). However the dot is not used in all the languages as a decimal separator. Most of the European countries, Russia and a lot of others countries uses a comma (',').

      With the corresponding Locale, the createNumber() method fails, throwing an exception.

      For example:

      Type.java
      public class Type {
      
          public static void main(final String[] args) {
              java.util.Locale.setDefault(java.util.Locale.GERMANY);
              String text = java.text.NumberFormat.getNumberInstance().format(12.34);
              Number nb = org.apache.commons.cli.TypeHandler.createNumber(text);
              System.out.println(nb);
          }
      }
      

      Attachments

        1. cli-226.diff
          8 kB
          Gary D. Gregory

        Activity

          People

            Unassigned Unassigned
            osechet Olivier Sechet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: