[threeten-dev] periodUntil(Temporal, TemporalUnit) does not work properly
patrick zhang
patrick.zhang at oracle.com
Wed Feb 27 23:59:57 PST 2013
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
More information about the threeten-dev
mailing list