@Test public void testCalculate() { assertEquals("计算有误", DateUtil.dateTime(DateUtil.calculate("2015-01-29 20:59:50", 9, "08:00-21:00")), "2015-01-29 20:59:59"); assertEquals("计算有误", DateUtil.dateTime(DateUtil.calculate("2015-01-29 20:59:50", 11, "08:00-21:00")), "2015-01-30 08:00:01"); assertEquals("计算有误", DateUtil.dateTime(DateUtil.calculate("2015-01-29 20:59:50", (3600 * 13 + 1), "08:00-21:00")), "2015-01-30 20:59:51"); assertEquals("计算有误", DateUtil.dateTime(DateUtil.calculate("2015-01-29 20:59:50", (3600 * 13 * 3 + 1), "08:00-21:00")), "2015-02-01 20:59:51"); assertEquals("计算有误", DateUtil.dateTime(DateUtil.calculate("2015-01-29 20:59:50", (3600 * 13 * 3 + 11), "08:00-21:00")), "2015-02-02 08:00:01"); assertEquals("计算有误", DateUtil.dateTime(DateUtil.calculate("2015-01-29 08:32:00", -35, "08:00-21:00")), "2015-01-29 08:31:25"); assertEquals("计算有误", DateUtil.dateTime(DateUtil.calculate("2015-01-29 08:00:30", -35, "08:00-21:00")), "2015-01-28 20:59:55"); assertEquals("计算有误", DateUtil.dateTime(DateUtil.calculate("2016-03-08 14:37:03", 16 * 60 * 60, "08:00-21:00")), "2016-03-09 17:37:03"); assertEquals("计算有误", DateUtil.dateTime(DateUtil.calculate("2015-01-29 08:00:30", Integer.parseInt("-" + (35 + 3600 * 13)), "08:00-21:00")), "2015-01-27 20:59:55"); assertEquals("计算有误", DateUtil.dateTime(DateUtil.calculate("2015-01-29 21:30:30", 35 + 3600 * 14, "08:00-21:00")), "2015-01-31 09:00:35"); assertEquals("计算有误", DateUtil.dateTime(DateUtil.calculate("2015-01-29 08:32:00", 3600 * 14, "08:00-21:00")), "2015-01-30 09:32:00"); }
public static Date calculate(String date, int second, String timeBurst) { Date start = null; try { start = DateTimeInstance().parse(date); return calculate(start, second, timeBurst); } catch (ParseException e) { e.printStackTrace(); } return new Date(); }
DateUtil { public static Date calculate(String date, int second, String timeBurst) { Date start = null; try { start = DateTimeInstance().parse(date); return calculate(start, second, timeBurst); } catch (ParseException e) { e.printStackTrace(); } return new Date(); } }
DateUtil { public static Date calculate(String date, int second, String timeBurst) { Date start = null; try { start = DateTimeInstance().parse(date); return calculate(start, second, timeBurst); } catch (ParseException e) { e.printStackTrace(); } return new Date(); }  }
DateUtil { public static Date calculate(String date, int second, String timeBurst) { Date start = null; try { start = DateTimeInstance().parse(date); return calculate(start, second, timeBurst); } catch (ParseException e) { e.printStackTrace(); } return new Date(); }  static String currentDateTime(); static String dateTime(Date date); static Date dateTime(String datestr); static String currentDate(); static String date(Date date); static Date date(String dateStr); static String currentTime(); static String time(Date date); static Date time(String dateStr); static Date year(int year); static Date year(Date date, int year); static Date month(int month); static Date month(Date date, int month); static Date day(int day); static Date day(Date date, int day); static Date hour(float hour); static Date hour(Date date, float hour); static Date minute(int minute); static Date minute(Date date, int minute); static boolean isDate(String date); static long subtract(Date date1, Date date2); static long subtract(String date1, String date2); static int subtractMinute(String date1, String date2); static int subtractMinute(Date date1, Date date2); static int subtractHour(Date date1, Date date2); static int subtractHour(String date1, String date2); static int subtractDay(String date1, String date2); static int subtractDay(Date date1, Date date2); static int subtractMonth(String date1, String date2); static int subtractMonth(Date date1, Date date2); static int subtractYear(String date1, String date2); static int subtractYear(Date date1, Date date2); static String subtractTime(String date1, String date2); static String subtractDate(String date1, String date2); static int subDay(Date startTime, Date endTime); static int subDay(String startTime, String endTime); static long subtimeBurst(String startDate, String endDate, String timeBurst); static long subtimeBurst(Date startDate, Date endDate, String timeBurst); static Date calculate(String date, int second, String timeBurst); static Date calculate(Date date, int second, String timeBurst); static boolean between(String startTime, String endTime, Date date); static boolean between(Date startTime, Date endTime, Date date); }
DateUtil { public static Date calculate(String date, int second, String timeBurst) { Date start = null; try { start = DateTimeInstance().parse(date); return calculate(start, second, timeBurst); } catch (ParseException e) { e.printStackTrace(); } return new Date(); }  static String currentDateTime(); static String dateTime(Date date); static Date dateTime(String datestr); static String currentDate(); static String date(Date date); static Date date(String dateStr); static String currentTime(); static String time(Date date); static Date time(String dateStr); static Date year(int year); static Date year(Date date, int year); static Date month(int month); static Date month(Date date, int month); static Date day(int day); static Date day(Date date, int day); static Date hour(float hour); static Date hour(Date date, float hour); static Date minute(int minute); static Date minute(Date date, int minute); static boolean isDate(String date); static long subtract(Date date1, Date date2); static long subtract(String date1, String date2); static int subtractMinute(String date1, String date2); static int subtractMinute(Date date1, Date date2); static int subtractHour(Date date1, Date date2); static int subtractHour(String date1, String date2); static int subtractDay(String date1, String date2); static int subtractDay(Date date1, Date date2); static int subtractMonth(String date1, String date2); static int subtractMonth(Date date1, Date date2); static int subtractYear(String date1, String date2); static int subtractYear(Date date1, Date date2); static String subtractTime(String date1, String date2); static String subtractDate(String date1, String date2); static int subDay(Date startTime, Date endTime); static int subDay(String startTime, String endTime); static long subtimeBurst(String startDate, String endDate, String timeBurst); static long subtimeBurst(Date startDate, Date endDate, String timeBurst); static Date calculate(String date, int second, String timeBurst); static Date calculate(Date date, int second, String timeBurst); static boolean between(String startTime, String endTime, Date date); static boolean between(Date startTime, Date endTime, Date date);  }