Fix roundToSecondPrecision when rounding up a second
This commit is contained in:
parent
dc9a997f5f
commit
472aeb6b6d
|
@ -497,11 +497,12 @@ public final class DateTimeUtils {
|
|||
? (T) temporal.plus( 1, ChronoUnit.SECONDS ).with( ChronoField.NANO_OF_SECOND, 0L )
|
||||
: (T) temporal.with( ChronoField.NANO_OF_SECOND, 0L );
|
||||
}
|
||||
final long nanos = roundToPrecision( temporal.get( ChronoField.NANO_OF_SECOND ), precision );
|
||||
if ( nanos == 1000000000L ) {
|
||||
return (T) temporal.plus( 1L, ChronoUnit.SECONDS ).with( ChronoField.NANO_OF_SECOND, 0L );
|
||||
}
|
||||
//noinspection unchecked
|
||||
return (T) temporal.with(
|
||||
ChronoField.NANO_OF_SECOND,
|
||||
roundToPrecision( temporal.get( ChronoField.NANO_OF_SECOND ), precision )
|
||||
);
|
||||
return (T) temporal.with( ChronoField.NANO_OF_SECOND, nanos );
|
||||
}
|
||||
|
||||
public static long roundToPrecision(int nano, int precision) {
|
||||
|
|
Loading…
Reference in New Issue