16
16
17
17
package com .fasterxml .jackson .datatype .jsr310 ;
18
18
19
+ import com .fasterxml .jackson .core .io .NumberInput ;
20
+
19
21
import java .math .BigDecimal ;
20
22
import java .time .Instant ;
21
23
import java .util .function .BiFunction ;
@@ -92,7 +94,7 @@ public static BigDecimal toBigDecimal(long seconds, int nanoseconds)
92
94
}
93
95
return BigDecimal .valueOf (seconds ).setScale (9 );
94
96
}
95
- return new BigDecimal (toDecimal (seconds , nanoseconds ));
97
+ return NumberInput . parseBigDecimal (toDecimal (seconds , nanoseconds ));
96
98
}
97
99
98
100
/**
@@ -104,7 +106,7 @@ public static int extractNanosecondDecimal(BigDecimal value, long integer)
104
106
// !!! 14-Mar-2016, tatu: Somewhat inefficient; should replace with functionally
105
107
// equivalent code that just subtracts integral part? (or, measure and show
106
108
// 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 ();
108
110
}
109
111
110
112
/**
@@ -136,7 +138,7 @@ else if (seconds.scale() < -63) {
136
138
else {
137
139
// Now we know that seconds has reasonable scale, we can safely chop it apart.
138
140
secondsOnly = seconds .longValue ();
139
- nanosOnly = nanoseconds .subtract (new BigDecimal (secondsOnly ).scaleByPowerOfTen (9 )).intValue ();
141
+ nanosOnly = nanoseconds .subtract (BigDecimal . valueOf (secondsOnly ).scaleByPowerOfTen (9 )).intValue ();
140
142
141
143
if (secondsOnly < 0 && secondsOnly > Instant .MIN .getEpochSecond ()) {
142
144
// Issue #69 and Issue #120: avoid sending a negative adjustment to the Instant constructor, we want this as the actual nanos
0 commit comments