Java Code Examples for org.apache.commons.lang3.time.DateUtils#truncatedCompareTo()
The following examples show how to use
org.apache.commons.lang3.time.DateUtils#truncatedCompareTo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserService.java From dubai with MIT License | 5 votes |
@Transactional(readOnly = false) public void activeUser(String key) { User user = userRepository.findByActKey(key); if (user == null || DateUtils.truncatedCompareTo(Calendar.getInstance().getTime(), user.getActKeyGenDate(), Calendar.HOUR) > 24 || DateUtils.truncatedCompareTo(user.getActDate(), user.getActKeyGenDate(), Calendar.MILLISECOND) > 0) { throw new ServiceException("激活码错误或者已失效。"); } user.setStatusCode(UserStatus.Active.code()); user.setActDate(Calendar.getInstance().getTime()); userRepository.save(user); }
Example 2
Source File: UserService.java From dubai with MIT License | 5 votes |
@Transactional(readOnly = false) public void resetPassword(String key) { User user = userRepository.findByActKey(key); if (user == null || DateUtils.truncatedCompareTo(Calendar.getInstance().getTime(), user.getActKeyGenDate(), Calendar.HOUR) > 24 || user.getActDate() != null) { throw new ServiceException("激活码错误或者已失效。"); } user.setStatusCode(UserStatus.Active.code()); user.setActDate(new Date()); userRepository.save(user); }
Example 3
Source File: CompareTwoDates.java From levelup-java-examples with Apache License 2.0 | 5 votes |
@Test public void compare_two_Dates_apachecommons() { Calendar sinceGraduation = Calendar.getInstance(); sinceGraduation.set(Calendar.YEAR, 1984); sinceGraduation.set(Calendar.MONTH, 6); sinceGraduation.set(Calendar.DAY_OF_MONTH, 4); Calendar today = Calendar.getInstance(); int val = DateUtils.truncatedCompareTo(sinceGraduation, today, Calendar.MINUTE); assertTrue(val <= 0); }
Example 4
Source File: DateUtil.java From seed with Apache License 2.0 | 4 votes |
/** * 判断是否本周第一天 */ public static boolean isFirstDayOfWeek(){ return 0 == DateUtils.truncatedCompareTo(new Date(), getFirstDayOfWeek(), Calendar.DAY_OF_MONTH); }