Johannes Schneider wrote:
> could anybody help me to get the following test run? The law (interest
> rate calculations) says that it is exactly 1 month and 0 days from 2-28
> till 3-30. Any suggestions?
>  {
>       DateMidnight begin = new DateMidnight( 2008, 2, 15 );
>       DateMidnight end = new DateMidnight( 2008, 3, 15 );
> 
>       Period period = new Period( begin, end, PeriodType.yearMonthDay() );
>       assertEquals( 1, period.getMonths() );
>       assertEquals( 0, period.getDays() );
>     }
> 
>     {
>       DateMidnight begin = new DateMidnight( 2008, 2, 28 );
>       DateMidnight end = new DateMidnight( 2008, 3, 30 );
> 
>       Period period = new Period( begin, end, PeriodType.yearMonthDay() );
>       assertEquals( 1, period.getMonths() );
>       assertEquals( 0, period.getDays() );
>     }

There is no direct functionality in Joda-Time that will answer this 
problem in the way you seek. Joda-Time does however provide all the 
tools you need to write the logic yourself. In particular, see the 
begin.dayOfMonth().getMaximumValue() method.

Stephen


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to