@Test public void testToDecimal01() { String decimal = DecimalUtils.toDecimal(0, 0); assertEquals("The returned decimal is not correct.", NO_NANOSECS_SER, decimal); decimal = DecimalUtils.toDecimal(15, 72); assertEquals("The returned decimal is not correct.", "15.000000072", decimal); decimal = DecimalUtils.toDecimal(19827342231L, 192837465); assertEquals("The returned decimal is not correct.", "19827342231.192837465", decimal); decimal = DecimalUtils.toDecimal(19827342231L, 0); assertEquals("The returned decimal is not correct.", "19827342231"+NO_NANOSECS_SUFFIX, decimal); decimal = DecimalUtils.toDecimal(19827342231L, 999888000); assertEquals("The returned decimal is not correct.", "19827342231.999888000", decimal); decimal = DecimalUtils.toDecimal(-22704862, 599000000); assertEquals("The returned decimal is not correct.", "-22704862.599000000", decimal); }
public static String toDecimal(long seconds, int nanoseconds) { StringBuilder sb = new StringBuilder(20) .append(seconds) .append('.'); if (nanoseconds == 0L) { if (seconds == 0L) { return "0.0"; } sb.append("000000000"); } else { StringBuilder nanoSB = new StringBuilder(9); nanoSB.append(nanoseconds); final int nanosLen = nanoSB.length(); int prepZeroes = 9 - nanosLen; while (prepZeroes > 0) { --prepZeroes; sb.append('0'); } sb.append(nanoSB); } return sb.toString(); }
DecimalUtils { public static String toDecimal(long seconds, int nanoseconds) { StringBuilder sb = new StringBuilder(20) .append(seconds) .append('.'); if (nanoseconds == 0L) { if (seconds == 0L) { return "0.0"; } sb.append("000000000"); } else { StringBuilder nanoSB = new StringBuilder(9); nanoSB.append(nanoseconds); final int nanosLen = nanoSB.length(); int prepZeroes = 9 - nanosLen; while (prepZeroes > 0) { --prepZeroes; sb.append('0'); } sb.append(nanoSB); } return sb.toString(); } }
DecimalUtils { public static String toDecimal(long seconds, int nanoseconds) { StringBuilder sb = new StringBuilder(20) .append(seconds) .append('.'); if (nanoseconds == 0L) { if (seconds == 0L) { return "0.0"; } sb.append("000000000"); } else { StringBuilder nanoSB = new StringBuilder(9); nanoSB.append(nanoseconds); final int nanosLen = nanoSB.length(); int prepZeroes = 9 - nanosLen; while (prepZeroes > 0) { --prepZeroes; sb.append('0'); } sb.append(nanoSB); } return sb.toString(); } private  DecimalUtils(); }
DecimalUtils { public static String toDecimal(long seconds, int nanoseconds) { StringBuilder sb = new StringBuilder(20) .append(seconds) .append('.'); if (nanoseconds == 0L) { if (seconds == 0L) { return "0.0"; } sb.append("000000000"); } else { StringBuilder nanoSB = new StringBuilder(9); nanoSB.append(nanoseconds); final int nanosLen = nanoSB.length(); int prepZeroes = 9 - nanosLen; while (prepZeroes > 0) { --prepZeroes; sb.append('0'); } sb.append(nanoSB); } return sb.toString(); } private  DecimalUtils(); static String toDecimal(long seconds, int nanoseconds); static BigDecimal toBigDecimal(long seconds, int nanoseconds); @Deprecated // since 2.9.8 static int extractNanosecondDecimal(BigDecimal value, long integer); static T extractSecondsAndNanos(BigDecimal seconds, BiFunction<Long, Integer, T> convert); }
DecimalUtils { public static String toDecimal(long seconds, int nanoseconds) { StringBuilder sb = new StringBuilder(20) .append(seconds) .append('.'); if (nanoseconds == 0L) { if (seconds == 0L) { return "0.0"; } sb.append("000000000"); } else { StringBuilder nanoSB = new StringBuilder(9); nanoSB.append(nanoseconds); final int nanosLen = nanoSB.length(); int prepZeroes = 9 - nanosLen; while (prepZeroes > 0) { --prepZeroes; sb.append('0'); } sb.append(nanoSB); } return sb.toString(); } private  DecimalUtils(); static String toDecimal(long seconds, int nanoseconds); static BigDecimal toBigDecimal(long seconds, int nanoseconds); @Deprecated // since 2.9.8 static int extractNanosecondDecimal(BigDecimal value, long integer); static T extractSecondsAndNanos(BigDecimal seconds, BiFunction<Long, Integer, T> convert);  }