@Test(expected = RuntimeException.class) public void testparseException() { Assert.assertEquals(86400000, TimeUtil.parse("1w")); }
public static long parse(String window) { char c = window.charAt(window.length() - 1); int num = Integer.parseInt(window.substring(0, window.length() - 1)); switch (c) { case 's': return num * 1000; case 'm': return num * 60 * 1000; case 'h': return num * 60 * 60 * 1000; case 'd': return num * 60 * 60 * 24 * 1000; default: throw new RuntimeException("error window format:" + window); } }
TimeUtil { public static long parse(String window) { char c = window.charAt(window.length() - 1); int num = Integer.parseInt(window.substring(0, window.length() - 1)); switch (c) { case 's': return num * 1000; case 'm': return num * 60 * 1000; case 'h': return num * 60 * 60 * 1000; case 'd': return num * 60 * 60 * 24 * 1000; default: throw new RuntimeException("error window format:" + window); } } }
TimeUtil { public static long parse(String window) { char c = window.charAt(window.length() - 1); int num = Integer.parseInt(window.substring(0, window.length() - 1)); switch (c) { case 's': return num * 1000; case 'm': return num * 60 * 1000; case 'h': return num * 60 * 60 * 1000; case 'd': return num * 60 * 60 * 24 * 1000; default: throw new RuntimeException("error window format:" + window); } } private  TimeUtil(); }
TimeUtil { public static long parse(String window) { char c = window.charAt(window.length() - 1); int num = Integer.parseInt(window.substring(0, window.length() - 1)); switch (c) { case 's': return num * 1000; case 'm': return num * 60 * 1000; case 'h': return num * 60 * 60 * 1000; case 'd': return num * 60 * 60 * 24 * 1000; default: throw new RuntimeException("error window format:" + window); } } private  TimeUtil(); static long str2Time(String timeStr); static String timestamp2ISODate(long timestamp); static long parse(String window); }
TimeUtil { public static long parse(String window) { char c = window.charAt(window.length() - 1); int num = Integer.parseInt(window.substring(0, window.length() - 1)); switch (c) { case 's': return num * 1000; case 'm': return num * 60 * 1000; case 'h': return num * 60 * 60 * 1000; case 'd': return num * 60 * 60 * 24 * 1000; default: throw new RuntimeException("error window format:" + window); } } private  TimeUtil(); static long str2Time(String timeStr); static String timestamp2ISODate(long timestamp); static long parse(String window);  }