Skip to content

Commit

Permalink
Update DecimalUtils.java
Browse files Browse the repository at this point in the history
seconds value already has the correct sign, so remove the sign from the nanos part
  • Loading branch information
kupci committed Aug 27, 2019
1 parent 812a598 commit b3588cf
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.fasterxml.jackson.datatype.jsr310;

import java.math.BigDecimal;
import java.time.Instant;
import java.util.function.BiFunction;

/**
Expand Down Expand Up @@ -136,6 +137,11 @@ else if (seconds.scale() < -63) {
// Now we know that seconds has reasonable scale, we can safely chop it apart.
secondsOnly = seconds.longValue();
nanosOnly = nanoseconds.subtract(new BigDecimal(secondsOnly).scaleByPowerOfTen(9)).intValue();


if (secondsOnly < 0 && secondsOnly > Instant.MIN.getEpochSecond()) {
nanosOnly = Math.abs(nanosOnly);
}
}

return convert.apply(secondsOnly, nanosOnly);
Expand Down

0 comments on commit b3588cf

Please # to comment.