1616
1717package com .fasterxml .jackson .datatype .jsr310 ;
1818
19+ import com .fasterxml .jackson .core .io .NumberInput ;
20+
1921import java .math .BigDecimal ;
2022import java .time .Instant ;
2123import java .util .function .BiFunction ;
@@ -92,7 +94,7 @@ public static BigDecimal toBigDecimal(long seconds, int nanoseconds)
9294 }
9395 return BigDecimal .valueOf (seconds ).setScale (9 );
9496 }
95- return new BigDecimal (toDecimal (seconds , nanoseconds ));
97+ return NumberInput . parseBigDecimal (toDecimal (seconds , nanoseconds ));
9698 }
9799
98100 /**
@@ -104,7 +106,7 @@ public static int extractNanosecondDecimal(BigDecimal value, long integer)
104106 // !!! 14-Mar-2016, tatu: Somewhat inefficient; should replace with functionally
105107 // equivalent code that just subtracts integral part? (or, measure and show
106108 // there's no difference and do nothing... )
107- return value .subtract (new BigDecimal (integer )).multiply (ONE_BILLION ).intValue ();
109+ return value .subtract (BigDecimal . valueOf (integer )).multiply (ONE_BILLION ).intValue ();
108110 }
109111
110112 /**
@@ -136,7 +138,7 @@ else if (seconds.scale() < -63) {
136138 else {
137139 // Now we know that seconds has reasonable scale, we can safely chop it apart.
138140 secondsOnly = seconds .longValue ();
139- nanosOnly = nanoseconds .subtract (new BigDecimal (secondsOnly ).scaleByPowerOfTen (9 )).intValue ();
141+ nanosOnly = nanoseconds .subtract (BigDecimal . valueOf (secondsOnly ).scaleByPowerOfTen (9 )).intValue ();
140142
141143 if (secondsOnly < 0 && secondsOnly > Instant .MIN .getEpochSecond ()) {
142144 // Issue #69 and Issue #120: avoid sending a negative adjustment to the Instant constructor, we want this as the actual nanos
0 commit comments