You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Naoya Sugioka <na...@gmail.com> on 2012/08/13 22:31:43 UTC

[lang] DurationFormatUtils formatPeriod

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


Re: [lang] DurationFormatUtils formatPeriod

Posted by Gary Gregory <ga...@gmail.com>.
Can you create a JIRA and attache a patch there?

Thank you,
Gary

On Mon, Aug 13, 2012 at 4:31 PM, Naoya Sugioka <na...@gmail.com>wrote:

> 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
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory