| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package com.goafanti.common.utils;
- import java.text.ParseException;
- import java.util.Date;
- import org.apache.commons.lang3.time.DateFormatUtils;
- import com.goafanti.common.constant.AFTConstants;
- import com.goafanti.core.shiro.token.TokenManager;
- public class TimeUtils {
- public static Boolean checkOverTime(String s) {
- Boolean flag = false;
- if ("getMCode".equals(s)) {
- if (System.currentTimeMillis()
- - (Long) TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE_TIME) > 60000) {
- flag = true;
- }
- } else if ("register".equals(s)) {
- if (System.currentTimeMillis()
- - (Long) TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE_TIME) > 900000) {
- flag = true;
- }
- } else if ("resetCode".equals(s)) {
- if (System.currentTimeMillis()
- - (Long) TokenManager.getSession().getAttribute(VerifyCodeUtils.RESET_CODE_TIME) > 600000) {
- flag = true;
- }
- }
- return flag;
- }
-
- public static Boolean checkCogExpire(Date issuingDate) throws ParseException{
- String d = DateFormatUtils.format(issuingDate, AFTConstants.YYYYMMDD);
- String suffix = d.substring(4, 10);
- int year = Integer.parseInt(d.substring(0, 3));
- int expireYear = year + 3;
- String expireDate = expireYear + suffix;
- Date expireDay = DateUtils.parseDate(expireDate, AFTConstants.YYYYMMDD);
-
- Date nowTime = new Date(System.currentTimeMillis());
-
- if (nowTime.getTime() - expireDay.getTime() > 0){
- return Boolean.TRUE;
- }
- return Boolean.FALSE;
- }
- }
|