AkInterval extends TClassBase { public static long secondsRawFrom(long source, TimeUnit sourceUnit) { return AkIntervalSecondsFormat.UNDERLYING_UNIT.convert(source, sourceUnit); } private <A extends Enum<A> & Attribute> AkInterval(TBundleID bundle, String name,
                                               Enum<?> category, Class<A> enumClass,
                                               TClassFormatter formatter,
                                               int internalRepVersion, int sVersion, int sSize,
                                               UnderlyingType underlyingType,
                                               A formatAttribute,
                                               IntervalFormat[] formatters); TClass widestComparable(); static long secondsIntervalAs(ValueSource source, TimeUnit as); static long secondsIntervalAs(long secondsIntervalRaw, TimeUnit as); static long secondsRawFrom(long source, TimeUnit sourceUnit); static long secondsRawFromFractionalSeconds(long source); @Override boolean attributeIsPhysical(int attributeIndex); @Override void attributeToString(int attributeIndex, long value, StringBuilder output); @Override TInstance instance(boolean nullable); @Override int jdbcType(); TInstance typeFrom(DataTypeDescriptor type); boolean isDate(TInstance ins); boolean isTime(TInstance ins); static final AkInterval MONTHS; static final AkInterval SECONDS; }
@Test public void conversionsForLong() { long nanos = new TimeBuilder() .add(3, TimeUnit.DAYS) .add(5, TimeUnit.HOURS) .add(13, TimeUnit.MINUTES) .add(17, TimeUnit.SECONDS) .add(43, TimeUnit.MICROSECONDS) .add(666, TimeUnit.NANOSECONDS) .getNanos(); long raw = AkInterval.secondsRawFrom(nanos, TimeUnit.NANOSECONDS); long amount; amount = checkAndGet(raw, TimeUnit.DAYS, 3); amount = checkAndGet(raw, TimeUnit.HOURS, (amount*24) + 5); amount = checkAndGet(raw, TimeUnit.MINUTES, (amount*60) + 13); amount = checkAndGet(raw, TimeUnit.SECONDS, (amount*60) + 17); amount = checkAndGet(raw, TimeUnit.MICROSECONDS, (amount*1000000) + 43); checkAndGet(raw, TimeUnit.NANOSECONDS, amount*1000); }