本文整理匯總了Java中org.apache.commons.lang.time.DateUtils.round方法的典型用法代碼示例。如果您正苦於以下問題:Java DateUtils.round方法的具體用法?Java DateUtils.round怎麽用?Java DateUtils.round使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.time.DateUtils
的用法示例。
在下文中一共展示了DateUtils.round方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkEvent
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public void checkEvent() {
Date expireEndTime = DateUtils.round(DateUtils.addSeconds(new Date(), 30), Calendar.MINUTE);
try {
processExpireEvents(expireEndTime);
} catch (CoreException ce) {
myLog.error(ce.getMessage(), ce);
}
}
示例2: equals
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* compares two Calendars on a certain precision level. <br>
* For example, if you had the datetime of 12 Mar 2011 14:31:07.847, and a second datetime of 12 Mar 2011 14:31:11.734, they would evaluate as
* equal on the Calendar.MINUTE level and above. They would evaluate as not equal on levels Calendar.SECOND and Calendar.MILLISECOND.<br>
* Fields are rounded, so 12 Mar 2011 14:31:07.847 and 12 Mar 2011 14:31:08.123 would evaluate as equal on the Calendar.SECOND level.
* @param cal1 if null, returns false
* @param cal2 if null, returns false
* @param level, for example Calendar.MINUTE
* @return true if equal on this level, false if not.
*/
public static boolean equals(final Calendar cal1, final Calendar cal2, final int level) {
if (cal1 == null || cal2 == null) {
return false;
}
final Calendar temp1 = DateUtils.round((Calendar) cal1.clone(), level);
final Calendar temp2 = DateUtils.round((Calendar) cal2.clone(), level);
return (temp1.equals(temp2));
}