DateUtils { public static long timeToMs(int day, int hour, int min, int sec) { return ((long) CONSTANT_1000) * (((day * CONSTANT_24 + hour) * CONSTANT_60 + min) * CONSTANT_60 + sec); }  static long getCollectTimeInLong(Date date); static Date convertToServerDate(String userTimeZone, Date userDate); static Date convertToUserDate(String userTimeZone, Date serverDate); static String dateToString(Date date); static Map<String, String> getFilteredTimeZoneMap(); static Date toSimpleDate(String strDate); static Date toDate(String strDate); static Date addDay(Date date, int days); static String ms2Time(long ms); static long timeToMs(int day, int hour, int min, int sec); static boolean compareDateEndWithMinute(Date d1, Date d2);  }
@Test public void testTimeToMs() { int day = 3; int hour = 1; int min = 1; int second = 1; long duration = DateUtils.timeToMs(day, hour, min, second); long expected = 1000L * ((((day * 24) + hour) * 60 + min) * 60 + second); assertThat(duration, is(expected)); day = 30; hour = 10; min = 10; second = 10; duration = DateUtils.timeToMs(day, hour, min, second); expected = 1000L * ((((day * 24) + hour) * 60 + min) * 60 + second); assertThat(duration, is(expected)); }