From 13a913428e28c412a2e77005779f2aef556200e9 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 26 Aug 2022 12:24:15 +1200 Subject: [PATCH] DecimalUtils - remove unused methods converting between Instance and BigDecimal --- .../server/type/DecimalUtils.java | 10 -------- .../server/type/DecimalUtilsTest.java | 23 +++++++------------ 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DecimalUtils.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DecimalUtils.java index 13ceb73c2..1e75c32a9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DecimalUtils.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DecimalUtils.java @@ -61,16 +61,6 @@ final class DecimalUtils { return new BigDecimal(toDecimal(secs, instant.getNanos())); } - static Instant toInstant(BigDecimal value) { - long seconds = value.longValue(); - int nanoseconds = extractNanosecondDecimal(value, seconds); - return Instant.ofEpochSecond(seconds, nanoseconds); - } - - static BigDecimal toDecimal(Instant instant) { - return new BigDecimal(toDecimal(instant.getEpochSecond(), instant.getNano())); - } - static String toDecimal(long seconds, int nanoseconds) { StringBuilder string = new StringBuilder(Integer.toString(nanoseconds)); if (string.length() < 9) diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/type/DecimalUtilsTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/type/DecimalUtilsTest.java index 7a7d19dd3..7f6d9f98a 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/type/DecimalUtilsTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/type/DecimalUtilsTest.java @@ -9,29 +9,22 @@ import java.time.Instant; import static org.junit.jupiter.api.Assertions.assertEquals; -public class DecimalUtilsTest { +class DecimalUtilsTest { @Test - public void testToDecimal() throws Exception { - + void testToDecimal() { Instant now = Instant.now(); - BigDecimal value = DecimalUtils.toDecimal(now); + Timestamp sourceTimestamp = Timestamp.from(now); - Instant instant = DecimalUtils.toInstant(value); - Timestamp timestamp = DecimalUtils.toTimestamp(value); - BigDecimal decimal = DecimalUtils.toDecimal(timestamp); + BigDecimal decimal = DecimalUtils.toDecimal(sourceTimestamp); + Timestamp timestamp = DecimalUtils.toTimestamp(decimal); - Instant instant1 = timestamp.toInstant(); - - assertEquals(instant, instant1); - assertEquals(value, decimal); - assertEquals(now, instant); + assertEquals(now, timestamp.toInstant()); + assertEquals(sourceTimestamp, timestamp); } @Test - public void testDuration() throws Exception { - - + void testDuration() { Duration duration = Duration.ofSeconds(323, 1500000); BigDecimal bigDecimal = DecimalUtils.toDecimal(duration);