/** * 设置秒, 0-59. */ public static Date setSeconds(@NotNull final Date date, int amount) { return DateUtils.setSeconds(date, amount); }
/** * 设置秒, 0-59. */ public static Date setSeconds(@NotNull final Date date, int amount) { return DateUtils.setSeconds(date, amount); }
@Test public void testSetSeconds() throws Exception { Date result = DateUtils.setSeconds(BASE_DATE, 0); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 0, 1); result = DateUtils.setSeconds(BASE_DATE, 59); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 59, 1); try { DateUtils.setSeconds(BASE_DATE, 60); fail("DateUtils.setSeconds did not throw an expected IllegalArgumentException."); } catch (final IllegalArgumentException e) { } }
/** * @return 精确到分钟的当前日期 */ public static Date getMinuteDate() { return DateUtils.addMinutes(DateUtils.setSeconds(DateUtils.setMilliseconds(getDate(), 0), 0), 1); }
/** * @return 精确到分钟的当前日期 */ public static Date getMinuteDate() { return DateUtils.addMinutes(DateUtils.setSeconds(DateUtils.setMilliseconds(getDate(), 0), 0), 1); }
/** * 设置秒, 0-59. */ public static Date setSeconds(@NotNull final Date date, int amount) { return DateUtils.setSeconds(date, amount); }
/** * 设置秒, 0-59. */ public static Date setSeconds(@NotNull final Date date, int amount) { return DateUtils.setSeconds(date, amount); }