/** Return a date object representing the start of the next minute from now */public Date nextMinuteFromNow() { long nowAsMillis = System.currentTimeMillis(); Date then = new Date(nowAsMillis + 60000); then.setSeconds(0); then.setMilliseconds(0); return then;}
public Date minuteAfter(Date now) { Date then = new Date(now.getTime() + 60000); then.setSeconds(0); then.setMilliseconds(0); return then;}// Retain original functionality@Deprecated public Date nextMinuteFromNow() { return minuteAfter(new Date(System.currentTimeMillis()));}
public void testMinuteAfter () { Date now = stringToDate("2012-12-22 11:59:59.999PM"); Date then = minuteAfter(now); assertEquals("2012-12-23 12:00:00.000AM", dateToString(then));}
No comments :
Post a Comment