Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-449

Advanced Java MessageFormat patterns not respected

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 1.6
    • 1.7
    • None
    • None

    Description

      Hi,

      I'm using a standard Java properties file, containing this :

      my.label = Year

      {0,date,yyyy}

      The problem I encountered is that this pattern is truncated while loading it with Apache Commons Configuration:

      (service code)
      // confPath being the path to an .xml file containing all the .properties file paths
      ConfigurationFactory configurationFactory = new ConfigurationFactory(confPath);
      configurationFactory.setBasePath(getApplicationRoot());
      configuration = configurationFactory.getConfiguration();

      (client code)
      String labelPattern = configuration.getString("my.label");

      I have labelPattern = Year {0
      which ended in the MessageFormat with a java.lang.IllegalArgumentException: Unmatched braces in the pattern.

      So I have to escape the commas in my pattern with a single backslash (here I had to enter two, because one backslash isn't displayed):

      my.label = Year

      {0\\,date\\,yyyy}

      Don't understand why..?!

      see http://download.oracle.com/javase/6/docs/api/java/text/MessageFormat.html

      Attachments

        Activity

          People

            Unassigned Unassigned
            maxxyme maxxyme
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: