[threeten-dev] periodUntil(Temporal, TemporalUnit) does not work properly

roger riggs roger.riggs at oracle.com
Thu Feb 28 06:54:08 PST 2013


Hi Patrick,

These are bugs.
The code delegates to the isoDate but does not supply the isoDate of the 
endDate.

I'll look into fixing it.

Roger

On 2/28/2013 2:59 AM, patrick zhang wrote:
> Hi Team,
>
> I am checking some functions in HijrahDate 
> <../../../java/time/chrono/HijrahDate.html>, JapaneseDate 
> <../../../java/time/chrono/JapaneseDate.html>, MinguoDate 
> <../../../java/time/chrono/MinguoDate.html> and ThaiBuddhistDate. 
> <../../../java/time/chrono/ThaiBuddhistDate.html>
> It looks periodUntil(Temporal, TemporalUnit) does not work properly.
>
> Any suggestion about it? The similar problem happens for all 4 classes.
>
> sample code:
> ==========================================
>         LocalDate date1 = LocalDate.of(1970, 1, 1) ;
>         LocalDate date2 = LocalDate.of(1968, 2, 10) ;
> System.out.println(date2.periodUntil(date1,ChronoUnit.DAYS)) ;
>
>         MinguoDate date3 = MinguoDate.of(1970, 1, 1) ;
>         MinguoDate date4 = MinguoDate.of(1968, 2, 10) ;
> System.out.println(date4.periodUntil(date3,ChronoUnit.DAYS)) ;
> ==========================================
>
> output:
> ==========================================
> 691
> Exception in thread "main" java.time.DateTimeException: Unable to 
> calculate period between objects of two different types
>     at java.time.LocalDate.periodUntil(LocalDate.java:1517)
>     at 
> java.time.chrono.ChronoDateImpl.periodUntil(ChronoDateImpl.java:334)
>     at java.time.chrono.MinguoDate.periodUntil(MinguoDate.java:96)
>     at mytest.TestMinguoDate.main(TestMinguoDate.java:20)
> ==========================================
>
> Regards
> Patrick

-- 
Thanks, Roger

Oracle Java Platform Group

Green Oracle <http://www.oracle.com/commitment> Oracle is committed to 
developing practices and products that help protect the environment



More information about the threeten-dev mailing list