4 Replies Latest reply on Mar 27, 2008 9:20 AM by alesj

    AbstractKernelTest and date handling

    alesj

      I've fixed/hacked the problem that's been bugging me from the beginning.
      Date handling inside MC was failing for me, since SimpleDateFormat by default takes default Locale.
      In my case this is Slovenian locale, but the test inputs day name as Mon, which is of course not recognized by my locale.

      I've put Locale.US to every possible place. :-)
      Now all the test finally pass for me locally. Yeay.

      Since it's date we're really interested in, its parsing/transformation, I don't see an issue in this Locale hack.

      Or is it? :-)

        • 1. Re: AbstractKernelTest and date handling

           

          "alesj" wrote:
          I've fixed/hacked the problem that's been bugging me from the beginning.
          Date handling inside MC was failing for me, since SimpleDateFormat by default takes default Locale.
          In my case this is Slovenian locale, but the test inputs day name as Mon, which is of course not recognized by my locale.

          I've put Locale.US to every possible place. :-)
          Now all the test finally pass for me locally. Yeay.

          Since it's date we're really interested in, its parsing/transformation, I don't see an issue in this Locale hack.

          Or is it? :-)


          Why don't you just hack the tests to set the locale to American.
          People should be able to inject dates in their own locale.
          I doubt it has many use cases anyway. ;-)

          • 2. Re: AbstractKernelTest and date handling

            The alternative would be to fix the Date property editor such that you can
            specify the locale in the string, e.g. as a prefix

            • 3. Re: AbstractKernelTest and date handling
              alesj

               

              "adrian@jboss.org" wrote:

              Why don't you just hack the tests to set the locale to American.

              That's what I did.
              "alesj" wrote:

              I've put Locale.US to every possible place. :-)


              • 4. Re: AbstractKernelTest and date handling
                alesj

                 

                "adrian@jboss.org" wrote:
                The alternative would be to fix the Date property editor such that you can
                specify the locale in the string, e.g. as a prefix

                That's what I also already did. ;-)
                - String defaultFormat = System.getProperty("org.jboss.util.propertyeditor.DateEditor.format",
                - "MMM d, yyyy");
                + String defaultFormat = System.getProperty("org.jboss.util.propertyeditor.DateEditor.format", "MMM d, yyyy");
                + String defaultLocale = System.getProperty("org.jboss.util.propertyeditor.DateEditor.locale");
                + DateFormat defaultDateFormat;
                + if (defaultLocale == null)
                + {
                + defaultDateFormat = new SimpleDateFormat(defaultFormat);
                + }
                + else
                + {
                + defaultDateFormat = new SimpleDateFormat(defaultFormat, Strings.parseLocaleString(defaultLocale));
                + }
                +
                 formats = new DateFormat[]
                 {
                - new SimpleDateFormat(defaultFormat),
                + defaultDateFormat,
                

                Just don't feel like waiting for the new commons release. :-)