mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
DecimalUtils - remove unused methods converting between Instance and BigDecimal
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user