[threeten-dev] Instant.with(TemporalField, long) does not throw ArithmeticException for numeric overflow error
Patrick Zhang
patrick.zhang at oracle.com
Sun Feb 17 07:32:25 PST 2013
I guess the same problem may occurs in Instant.with(TemporalAdjuster
adjuster) and Instant.adjustInto(Temporal) since they work with similar
function. Will check it later.
Regards
Patrick
On 2/17/13 11:27 PM, Patrick Zhang wrote:
> Hi Team,
>
> I have found such a problem during creating new test code for
> java.time.Instant.
> It can be reproduced easily by below:
>
> Instant i1 = Instant.ofEpochSecond(1, -10) ;
> Instant i3 = i1.with(ChronoField.NANO_OF_SECOND,
> 1000000000L);
>
> As javadoc description, it should throw ArithmeticException since
> range of NANO_OF_SECOND is 0-999999999.
>
> Actually it throws DateTimeException,
> =======
> Exception in thread "main" java.time.DateTimeException: Invalid value
> for NanoOfSecond (valid values 0 - 999999999): 1000000000
> at java.time.temporal.ValueRange.checkValidValue(ValueRange.java:309)
> at
> java.time.temporal.ChronoField.checkValidValue(ChronoField.java:583)
> at java.time.Instant.with(Instant.java:632)
> at Test1.f1(Test1.java:14)
> at Test1.main(Test1.java:5)
> =======
>
> Regards
> Patrick
More information about the threeten-dev
mailing list