Class DecimalUtils
java.lang.Object
tools.jackson.databind.ext.javatime.util.DecimalUtils
Utilities to aid in the translation of decimal types to/from multiple parts.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TextractSecondsAndNanos(BigDecimal seconds, BiFunction<Long, Integer, T> convert, boolean negativeAdjustment) Extracts the seconds and nanoseconds component ofsecondsaslongandintvalues, passing them to the given converter.static BigDecimaltoBigDecimal(long seconds, int nanoseconds) Factory method for constructingBigDecimalout of second, nano-second components.static StringtoDecimal(long seconds, int nanoseconds)
-
Constructor Details
-
DecimalUtils
private DecimalUtils()
-
-
Method Details
-
toDecimal
-
toBigDecimal
Factory method for constructingBigDecimalout of second, nano-second components.- Parameters:
seconds- Seconds componentnanoseconds- Nanoseconds component- Returns:
- BigDecimal representation
- Throws:
ArithmeticException- if the calculation overflows or produces invalid results
-
extractSecondsAndNanos
public static <T> T extractSecondsAndNanos(BigDecimal seconds, BiFunction<Long, Integer, T> convert, boolean negativeAdjustment) Extracts the seconds and nanoseconds component ofsecondsaslongandintvalues, passing them to the given converter. The implementation avoids latency issues present on some JRE releases.- Type Parameters:
T- The return type of the converter function- Parameters:
seconds- The decimal seconds value to extract components fromconvert- Function to convert the extracted seconds and nanoseconds into result typenegativeAdjustment- Whether to adjust negative nanoseconds- Returns:
- The result of applying the converter function
- Throws:
ArithmeticException- if the calculation overflows or produces invalid results- Since:
- 2.19
-