Commons Lang
  1. Commons Lang
  2. LANG-117

[lang] FastDateFormat: wrong format for date "01.01.1000"

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.2
    • Component/s: lang.time.*
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: PC

      Description

      FastDateFromat.getInstance("dd.MM.yyyy").format(date) returns "01.01.01000",
      when date is 1 Januar 1000 (01.01.1000)

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Resolved Resolved Closed Closed
        286d 1h 58m 1 Henri Yandell 06/Feb/07 23:47
        Mark Thomas made changes -
        Workflow jira [ 12371955 ] Default workflow, editable Closed status [ 12602315 ]
        Henri Yandell made changes -
        Component/s lang.time.* [ 12313196 ]
        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Henri Yandell made changes -
        Fix Version/s 2.2 [ 12311702 ]
        Henri Yandell made changes -
        Affects Version/s 2.1 Final [ 12311701 ]
        Henri Yandell made changes -
        Component/s Lang [ 12311121 ]
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Key COM-2898 LANG-117
        Project Commons [ 12310458 ] Commons Lang [ 12310481 ]
        Affects Version/s 2.1 Final [ 12311659 ]
        Fix Version/s 2.2 [ 12311686 ]
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 39410 12343050
        Hide
        Henri Yandell added a comment -

        Adding unit test for #39410. Implementing fix by switching from using Math.log
        to Integer.toString to figure out the number of digits.

        Sending src/java/org/apache/commons/lang/time/FastDateFormat.java
        Sending src/test/org/apache/commons/lang/time/FastDateFormatTest.java
        Transmitting file data ..
        Committed revision 398530.

        Show
        Henri Yandell added a comment - Adding unit test for #39410. Implementing fix by switching from using Math.log to Integer.toString to figure out the number of digits. Sending src/java/org/apache/commons/lang/time/FastDateFormat.java Sending src/test/org/apache/commons/lang/time/FastDateFormatTest.java Transmitting file data .. Committed revision 398530.
        Hide
        Henri Yandell added a comment -

        Running through the source, the problem is that:

        log(1000) / log(10) is 2.9999999999999996 and not 3.0 as it should.

        Solving this by simplifying the method of finding out how many digits there are
        in a number - Integer.toString(value).length(). I've added an assert for value
        being negative (using Validate). Just in case.

        Show
        Henri Yandell added a comment - Running through the source, the problem is that: log(1000) / log(10) is 2.9999999999999996 and not 3.0 as it should. Solving this by simplifying the method of finding out how many digits there are in a number - Integer.toString(value).length(). I've added an assert for value being negative (using Validate). Just in case.
        Hide
        Henri Yandell added a comment -

        Created an attachment (id=18210)
        Unit test

        Show
        Henri Yandell added a comment - Created an attachment (id=18210) Unit test
        Hide
        Andriy Binetsky added a comment -
            • COM-2897 has been marked as a duplicate of this bug. ***
        Show
        Andriy Binetsky added a comment - COM-2897 has been marked as a duplicate of this bug. ***
        Hide
        Andriy Binetsky added a comment -

        for version 2.0 all is OK.

        Show
        Andriy Binetsky added a comment - for version 2.0 all is OK.
        Andriy Binetsky created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Andriy Binetsky
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development