@Test(expected = IllegalArgumentException.class) public void testErrorUnknownUnit() { durationSeconds("1w"); }
public static Integer durationSeconds(String duration) { BigDecimal ns = durationNs(duration); if (ns == null) { return null; } BigDecimal sec = ns.divide(new BigDecimal(1_000_000_000)); if (sec.compareTo(new BigDecimal(Integer.MAX_VALUE)) > 0) { throw new IllegalArgumentException("Integer Overflow"); } return sec.intValue(); }
GoTimeUtil { public static Integer durationSeconds(String duration) { BigDecimal ns = durationNs(duration); if (ns == null) { return null; } BigDecimal sec = ns.divide(new BigDecimal(1_000_000_000)); if (sec.compareTo(new BigDecimal(Integer.MAX_VALUE)) > 0) { throw new IllegalArgumentException("Integer Overflow"); } return sec.intValue(); } }
GoTimeUtil { public static Integer durationSeconds(String duration) { BigDecimal ns = durationNs(duration); if (ns == null) { return null; } BigDecimal sec = ns.divide(new BigDecimal(1_000_000_000)); if (sec.compareTo(new BigDecimal(Integer.MAX_VALUE)) > 0) { throw new IllegalArgumentException("Integer Overflow"); } return sec.intValue(); } private  GoTimeUtil(); }
GoTimeUtil { public static Integer durationSeconds(String duration) { BigDecimal ns = durationNs(duration); if (ns == null) { return null; } BigDecimal sec = ns.divide(new BigDecimal(1_000_000_000)); if (sec.compareTo(new BigDecimal(Integer.MAX_VALUE)) > 0) { throw new IllegalArgumentException("Integer Overflow"); } return sec.intValue(); } private  GoTimeUtil(); static Integer durationSeconds(String duration); static BigDecimal durationNs(String durationP); }
GoTimeUtil { public static Integer durationSeconds(String duration) { BigDecimal ns = durationNs(duration); if (ns == null) { return null; } BigDecimal sec = ns.divide(new BigDecimal(1_000_000_000)); if (sec.compareTo(new BigDecimal(Integer.MAX_VALUE)) > 0) { throw new IllegalArgumentException("Integer Overflow"); } return sec.intValue(); } private  GoTimeUtil(); static Integer durationSeconds(String duration); static BigDecimal durationNs(String durationP);  }