You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "stlum9495 (JIRA)" <ji...@apache.org> on 2006/10/05 18:52:22 UTC
[jira] Created: (LANG-281) DurationFormatUtils returns wrong result
DurationFormatUtils returns wrong result
----------------------------------------
Key: LANG-281
URL: http://issues.apache.org/jira/browse/LANG-281
Project: Commons Lang
Issue Type: Bug
Affects Versions: 2.2, 2.1
Environment: Win xp pro
Reporter: stlum9495
DurationFormatUtils returns wrong result. oddly, it is only when Date is set to Dec 31, 2005
The following code will result in a String of -2 which is way off.
I've tested against 2.1 and 2.2.
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, Calendar.DECEMBER);
cal.set(Calendar.DAY_OF_MONTH, 31);
cal.set(Calendar.YEAR, 2005);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
String result = DurationFormatUtils.formatPeriod(cal.getTimeInMillis(), System.currentTimeMillis(), "MM");
System.out.println(result);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Resolved: (LANG-281) DurationFormatUtils returns wrong
result
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-281?page=all ]
Henri Yandell resolved LANG-281.
--------------------------------
Resolution: Fixed
svn ci -m "Adding a unit test for #LANG-281 and a fix. The fix involves removing the reduceAndCorrect method. It appears that this method was doing sod all - which is worrying as it used to be important. I'm guessing that it was a bad fix for a bug that was then subsequently fixed with other code. I'll create a JIRA issue to create more tests to test out the +31 block of code. "
Sending src/java/org/apache/commons/lang/time/DurationFormatUtils.java
Sending src/test/org/apache/commons/lang/time/DurationFormatUtilsTest.java
Transmitting file data ..
Committed revision 453818.
> DurationFormatUtils returns wrong result
> ----------------------------------------
>
> Key: LANG-281
> URL: http://issues.apache.org/jira/browse/LANG-281
> Project: Commons Lang
> Issue Type: Bug
> Affects Versions: 2.1, 2.2
> Environment: Win xp pro
> Reporter: stlum9495
> Fix For: 2.3
>
> Attachments: LANG-281-fix.patch, LANG-281-test.patch
>
>
> DurationFormatUtils returns wrong result. oddly, it is only when Date is set to Dec 31, 2005
> The following code will result in a String of -2 which is way off.
> I've tested against 2.1 and 2.2.
> Calendar cal = Calendar.getInstance();
> cal.set(Calendar.MONTH, Calendar.DECEMBER);
> cal.set(Calendar.DAY_OF_MONTH, 31);
> cal.set(Calendar.YEAR, 2005);
> cal.set(Calendar.HOUR_OF_DAY, 0);
> cal.set(Calendar.MINUTE, 0);
> cal.set(Calendar.SECOND, 0);
> cal.set(Calendar.MILLISECOND, 0);
> String result = DurationFormatUtils.formatPeriod(cal.getTimeInMillis(), System.currentTimeMillis(), "MM");
> System.out.println(result);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-281) DurationFormatUtils returns wrong result
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-281?page=all ]
Henri Yandell updated LANG-281:
-------------------------------
Attachment: LANG-281-test.patch
Unit test attached.
> DurationFormatUtils returns wrong result
> ----------------------------------------
>
> Key: LANG-281
> URL: http://issues.apache.org/jira/browse/LANG-281
> Project: Commons Lang
> Issue Type: Bug
> Affects Versions: 2.1, 2.2
> Environment: Win xp pro
> Reporter: stlum9495
> Fix For: 2.3
>
> Attachments: LANG-281-test.patch
>
>
> DurationFormatUtils returns wrong result. oddly, it is only when Date is set to Dec 31, 2005
> The following code will result in a String of -2 which is way off.
> I've tested against 2.1 and 2.2.
> Calendar cal = Calendar.getInstance();
> cal.set(Calendar.MONTH, Calendar.DECEMBER);
> cal.set(Calendar.DAY_OF_MONTH, 31);
> cal.set(Calendar.YEAR, 2005);
> cal.set(Calendar.HOUR_OF_DAY, 0);
> cal.set(Calendar.MINUTE, 0);
> cal.set(Calendar.SECOND, 0);
> cal.set(Calendar.MILLISECOND, 0);
> String result = DurationFormatUtils.formatPeriod(cal.getTimeInMillis(), System.currentTimeMillis(), "MM");
> System.out.println(result);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-281) DurationFormatUtils returns wrong result
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-281?page=all ]
Henri Yandell updated LANG-281:
-------------------------------
Attachment: LANG-281-fix.patch
Attaching a fix. It's not a very good sign that I'm fixing this by deleting a block of code and discovering that no unit tests are suddenly failling. So I need to add more unit tests, and rethink things.
The block of code removed was meant to fix an overshooting when blindly adding 31 days instead of a known month number and I've also changed that to add the number of days in the previous month (with a big TODO to review it).
First step, make some unit tests to identify this case as apparantly I've not got them currently.
> DurationFormatUtils returns wrong result
> ----------------------------------------
>
> Key: LANG-281
> URL: http://issues.apache.org/jira/browse/LANG-281
> Project: Commons Lang
> Issue Type: Bug
> Affects Versions: 2.1, 2.2
> Environment: Win xp pro
> Reporter: stlum9495
> Fix For: 2.3
>
> Attachments: LANG-281-fix.patch, LANG-281-test.patch
>
>
> DurationFormatUtils returns wrong result. oddly, it is only when Date is set to Dec 31, 2005
> The following code will result in a String of -2 which is way off.
> I've tested against 2.1 and 2.2.
> Calendar cal = Calendar.getInstance();
> cal.set(Calendar.MONTH, Calendar.DECEMBER);
> cal.set(Calendar.DAY_OF_MONTH, 31);
> cal.set(Calendar.YEAR, 2005);
> cal.set(Calendar.HOUR_OF_DAY, 0);
> cal.set(Calendar.MINUTE, 0);
> cal.set(Calendar.SECOND, 0);
> cal.set(Calendar.MILLISECOND, 0);
> String result = DurationFormatUtils.formatPeriod(cal.getTimeInMillis(), System.currentTimeMillis(), "MM");
> System.out.println(result);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-281) DurationFormatUtils returns wrong result
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-281?page=all ]
Henri Yandell updated LANG-281:
-------------------------------
Attachment: (was: LANG-281-test.patch)
> DurationFormatUtils returns wrong result
> ----------------------------------------
>
> Key: LANG-281
> URL: http://issues.apache.org/jira/browse/LANG-281
> Project: Commons Lang
> Issue Type: Bug
> Affects Versions: 2.1, 2.2
> Environment: Win xp pro
> Reporter: stlum9495
> Fix For: 2.3
>
>
> DurationFormatUtils returns wrong result. oddly, it is only when Date is set to Dec 31, 2005
> The following code will result in a String of -2 which is way off.
> I've tested against 2.1 and 2.2.
> Calendar cal = Calendar.getInstance();
> cal.set(Calendar.MONTH, Calendar.DECEMBER);
> cal.set(Calendar.DAY_OF_MONTH, 31);
> cal.set(Calendar.YEAR, 2005);
> cal.set(Calendar.HOUR_OF_DAY, 0);
> cal.set(Calendar.MINUTE, 0);
> cal.set(Calendar.SECOND, 0);
> cal.set(Calendar.MILLISECOND, 0);
> String result = DurationFormatUtils.formatPeriod(cal.getTimeInMillis(), System.currentTimeMillis(), "MM");
> System.out.println(result);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-281) DurationFormatUtils returns wrong result
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-281?page=all ]
Henri Yandell updated LANG-281:
-------------------------------
Attachment: LANG-281-test.patch
Attached unit test.
> DurationFormatUtils returns wrong result
> ----------------------------------------
>
> Key: LANG-281
> URL: http://issues.apache.org/jira/browse/LANG-281
> Project: Commons Lang
> Issue Type: Bug
> Affects Versions: 2.1, 2.2
> Environment: Win xp pro
> Reporter: stlum9495
> Fix For: 2.3
>
> Attachments: LANG-281-test.patch
>
>
> DurationFormatUtils returns wrong result. oddly, it is only when Date is set to Dec 31, 2005
> The following code will result in a String of -2 which is way off.
> I've tested against 2.1 and 2.2.
> Calendar cal = Calendar.getInstance();
> cal.set(Calendar.MONTH, Calendar.DECEMBER);
> cal.set(Calendar.DAY_OF_MONTH, 31);
> cal.set(Calendar.YEAR, 2005);
> cal.set(Calendar.HOUR_OF_DAY, 0);
> cal.set(Calendar.MINUTE, 0);
> cal.set(Calendar.SECOND, 0);
> cal.set(Calendar.MILLISECOND, 0);
> String result = DurationFormatUtils.formatPeriod(cal.getTimeInMillis(), System.currentTimeMillis(), "MM");
> System.out.println(result);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-281) DurationFormatUtils returns wrong result
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-281?page=all ]
Henri Yandell updated LANG-281:
-------------------------------
Fix Version/s: 2.3
Setting for a 2.3 fix version (ie the version being worked on now). I'm starting to hate this class, yet another edge case.
Thanks for finding it though :)
> DurationFormatUtils returns wrong result
> ----------------------------------------
>
> Key: LANG-281
> URL: http://issues.apache.org/jira/browse/LANG-281
> Project: Commons Lang
> Issue Type: Bug
> Affects Versions: 2.1, 2.2
> Environment: Win xp pro
> Reporter: stlum9495
> Fix For: 2.3
>
>
> DurationFormatUtils returns wrong result. oddly, it is only when Date is set to Dec 31, 2005
> The following code will result in a String of -2 which is way off.
> I've tested against 2.1 and 2.2.
> Calendar cal = Calendar.getInstance();
> cal.set(Calendar.MONTH, Calendar.DECEMBER);
> cal.set(Calendar.DAY_OF_MONTH, 31);
> cal.set(Calendar.YEAR, 2005);
> cal.set(Calendar.HOUR_OF_DAY, 0);
> cal.set(Calendar.MINUTE, 0);
> cal.set(Calendar.SECOND, 0);
> cal.set(Calendar.MILLISECOND, 0);
> String result = DurationFormatUtils.formatPeriod(cal.getTimeInMillis(), System.currentTimeMillis(), "MM");
> System.out.println(result);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org