commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary D. Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LANG-815) DurationFormatUtils.formatPeriod() miss-calcuration
Date Tue, 28 Aug 2012 21:13:07 GMT

    [ https://issues.apache.org/jira/browse/LANG-815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13443537#comment-13443537
] 

Gary D. Gregory edited comment on LANG-815 at 8/29/12 8:11 AM:
---------------------------------------------------------------

This patch breaks a unit test:

{noformat}
junit.framework.ComparisonFailure: expected:<01 2[6]> but was:<01 2[3]>
	at junit.framework.Assert.assertEquals(Assert.java:85)
	at junit.framework.Assert.assertEquals(Assert.java:91)
	at org.apache.commons.lang3.time.DurationFormatUtilsTest.assertEqualDuration(DurationFormatUtilsTest.java:553)
	at org.apache.commons.lang3.time.DurationFormatUtilsTest.assertEqualDuration(DurationFormatUtilsTest.java:540)
	at org.apache.commons.lang3.time.DurationFormatUtilsTest.testEdgeDurations(DurationFormatUtilsTest.java:421)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
{noformat}

- Base your patch on trunk
- Please provide a unit test to cover your specific case.
- Make sure existing tests break (unless there is a bug in the test itself.)

Thank you.


                
      was (Author: garydgregory):
    This patch breaks a unit test:

                  
> DurationFormatUtils.formatPeriod() miss-calcuration
> ---------------------------------------------------
>
>                 Key: LANG-815
>                 URL: https://issues.apache.org/jira/browse/LANG-815
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.time.*
>    Affects Versions: 3.1
>         Environment: JDK 1.7
>            Reporter: Naoya Sugioka
>         Attachments: duration-format.diff
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Hello,
> I just encountered an issue with DurationFormatUtils.formatPeriod()
> and here I suggest the patch.
> The problem is found when calcurating a duration between  June 30 to August 8.
> Duration must be 1 month and 9 days  (June 30 + 1 month = July 30,
> July 30 + 9 Days = August 8)
> but current logic tells this duration is 1 month and 8 days.
> then I found out the logic to adjust days value if it was negative by
> initial estimate. it uses start date
> (June in above case) but must use prev month of end date (July in
> above case). then days value was
> wrong since getActualMaximum() will return a wrong number.
> thank you,
> -Naoya

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message