Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-799

DateUtils#parseDate uses default locale; add Locale support

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1
    • 3.2
    • lang.time.*

    Description

      Similar issue as https://issues.apache.org/jira/browse/HTTPCLIENT-471

      Following line throws an ParseException on a German system:
      d = DateUtils.parseDate("Wed, 09 Apr 2008 23:55:38 GMT", new String[]

      {"EEE, dd MMM yyyy HH:mm:ss zzz"}

      );

      Reason: parseDate internally calls SimpleDateFormat without providing a locale. This causes "MMM" to be interpreted using the system locale. If the system is German, the date is trying to be interpreted as German date.

      I see following solutions:
      A) Always instantiate SimpleDateFormat with Locale.ENGLISH
      B) Make two instances of SimpleDateFormat. One without providing a locale and one with Locale.ENGLISH. Try two parsings
      C) Make as many SimpleDateFormat instances as locales are availble iterate over all instances at the parsing attempts.
      D) provide an additional (optional) parameter to parseDate for providing a Locale

      I would prefer B) as this seems the best trade-off between internationalization and local usage.

      What do you think?

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            koppor Oliver Kopp
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified

                Slack

                  Issue deployment