當前位置: 首頁>>代碼示例>>Java>>正文


Java DateUtils.addMinutes方法代碼示例

本文整理匯總了Java中org.apache.commons.lang.time.DateUtils.addMinutes方法的典型用法代碼示例。如果您正苦於以下問題:Java DateUtils.addMinutes方法的具體用法?Java DateUtils.addMinutes怎麽用?Java DateUtils.addMinutes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang.time.DateUtils的用法示例。


在下文中一共展示了DateUtils.addMinutes方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateResetPasswordToken

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
protected String generateResetPasswordToken(UUID userId) {
    String token = RandomStringUtils.randomAlphanumeric(ResetPasswordToken.TOKEN_LENGTH);
    int lifetime = forgotPasswordConfig.getResetPasswordTokenLifetimeMinutes();

    try (Transaction tx = persistence.getTransaction()) {
        EntityManager em = persistence.getEntityManager();

        TypedQuery<ResetPasswordToken> query = em.createQuery(
                "select rp from nxsecfp$ResetPasswordToken rp where rp.user.id = :userId",
                ResetPasswordToken.class);
        query.setParameter("userId", userId);

        ResetPasswordToken resetPasswordToken = query.getFirstResult();

        if (resetPasswordToken == null) {
            resetPasswordToken = metadata.create(ResetPasswordToken.class);
            resetPasswordToken.setUser(em.getReference(User.class, userId));
        }
        Date expires = DateUtils.addMinutes(timeSource.currentTimestamp(), lifetime);
        resetPasswordToken.setToken(token);
        resetPasswordToken.setExpireAt(expires);

        em.persist(resetPasswordToken);

        tx.commit();
    }

    return token;
}
 
開發者ID:pfurini,項目名稱:cuba-component-forgot-password,代碼行數:30,代碼來源:NexbitUserManagementServiceBean.java

示例2: registerTryEvent

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public SecqMeEventVO registerTryEvent(Integer eventDurationInMinutes) throws CoreException {
    // use the List of user to register the Trial Event base on the Time
    Date startTime = new Date();
    Date endTime = DateUtils.addMinutes(startTime, eventDurationInMinutes);
    Long index = (startTime.getTime() % demoUserIDList.size());
    String trialUserID = this.demoUserIDList.get(index.intValue());
    UserVO userVO = getUserDAO().read(trialUserID);
    myLog.debug("Register trial event via demo User->" + userVO.getUserid());
    SecqMeEventVO eventVO = new SecqMeEventVO();
    eventVO.setMessage("Watch Over Me");
    eventVO.setUserVO(userVO);
    eventVO.setEventType(EventType.NORMAL);
    eventVO.setEnableGPS(true);
    eventVO.setStartTime(startTime);
    eventVO.setEndTime(endTime);
    eventVO.setStatus(EventStatusType.NEW);
    String trackingPin = getTextUtil().generateRandomString(6, 7);
    eventVO.setTrackingPin(trackingPin);
    try {
        String trackingURL = getUrlShortenerService().getShortURL(trackingBaseURL + trackingPin, "tracking");
        eventVO.setTrackingURL(trackingURL);
    } catch (ShortURLException ex) {
        myLog.error("Failed to generate short url for: " + trackingBaseURL + trackingPin, ex);
    }

    getSecqMeEventDAO().create(eventVO);
    insertEventLogRecord(eventVO, EventStatusType.NEW, "Received", null, null, null);
    getScheduleManager().scheduleCheckExpireEventJob(eventVO);
    return eventVO;
}
 
開發者ID:SECQME,項目名稱:watchoverme-server,代碼行數:31,代碼來源:DefaultEventManager.java

示例3: findReferralLogAvailableHTMLParameters

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public List<ReferralLogVO> findReferralLogAvailableHTMLParameters(ReferralClickType clickType,
                                                                  String requestIP,
                                                                  Integer intervalInMinutes) {
    Date endTime = new Date();
    Date startTime = DateUtils.addMinutes(endTime, -intervalInMinutes);
    myLog.debug("Finding referralLog startTime->" + startTime + "," + endTime + ", clickType->" + clickType);

    JPAParameter parameters = new JPAParameter().setParameter("clickType", clickType)
            .setParameter("startTime", startTime)
            .setParameter("endTime", endTime)
            .setParameter("requestIP", requestIP);

    return executeQueryWithResultList(ReferralLogVO.QUERY_FIND_BY_HTML_PARAMETERS, parameters);
}
 
開發者ID:SECQME,項目名稱:watchoverme-server,代碼行數:15,代碼來源:ReferralLogJPADAO.java

示例4: testVerifyTokenDate

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@Test
    public void testVerifyTokenDate()
    {
        Date testDate1 = DateUtils.setMinutes ( new Date( System.currentTimeMillis() ), 3 );
        Date testDate2 = DateUtils.addMinutes (  new Date( System.currentTimeMillis() ), 2 );

        String token1 = createToken(testDate1);
        String token2 = createToken(testDate2);

        //long expDate = TokenUtils.getDate( token2 );

//        assertFalse( TokenUtil.verifyToken( token1, tokenSecret ) );
        assertTrue( TokenUtil.verifyToken( token2, tokenSecret ) );
    }
 
開發者ID:subutai-io,項目名稱:base,代碼行數:15,代碼來源:TokenUtilTest.java

示例5: invalidateSessions

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@Test
public void invalidateSessions()
{
    Date currentDate = DateUtils.addMinutes(session.getStartDate(), sessionManager.getSessionTimeout());

    System.out.println( "Session Time:" + session.getEndDate() + "\nCurrentTime:"+ currentDate);
    assertTrue( session.getEndDate().getTime() <= currentDate.getTime() );

    sessionManager.invalidateSessions( currentDate );

    assertNull( sessionManager.getValidSession(sessionId));
}
 
開發者ID:subutai-io,項目名稱:base,代碼行數:13,代碼來源:SessionManagerImplTest.java

示例6: doGetAuthenticationInfo

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
 * 獲取認證信息
 * 
 * @param token
 *            令牌
 * @return 認證信息
 */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken token) {
	AuthenticationToken authenticationToken = (AuthenticationToken) token;
	String username = authenticationToken.getUsername();
	String password = new String(authenticationToken.getPassword());
	String captchaId = authenticationToken.getCaptchaId();
	String captcha = authenticationToken.getCaptcha();
	String ip = authenticationToken.getHost();
	if (!captchaService.isValid(CaptchaType.adminLogin, captchaId, captcha)) {
		throw new UnsupportedTokenException();
	}
	if (username != null && password != null) {
		Admin admin = adminService.findByUsername(username);
		if (admin == null) {
			throw new UnknownAccountException();
		}
		if (!admin.getIsEnabled()) {
			throw new DisabledAccountException();
		}
		Setting setting = SettingUtils.get();
		if (admin.getIsLocked()) {
			if (ArrayUtils.contains(setting.getAccountLockTypes(), AccountLockType.admin)) {
				int loginFailureLockTime = setting.getAccountLockTime();
				if (loginFailureLockTime == 0) {
					throw new LockedAccountException();
				}
				Date lockedDate = admin.getLockedDate();
				Date unlockDate = DateUtils.addMinutes(lockedDate, loginFailureLockTime);
				if (new Date().after(unlockDate)) {
					admin.setLoginFailureCount(0);
					admin.setIsLocked(false);
					admin.setLockedDate(null);
					adminService.update(admin);
				} else {
					throw new LockedAccountException();
				}
			} else {
				admin.setLoginFailureCount(0);
				admin.setIsLocked(false);
				admin.setLockedDate(null);
				adminService.update(admin);
			}
		}
		if (!DigestUtils.md5Hex(password).equals(admin.getPassword())) {
			int loginFailureCount = admin.getLoginFailureCount() + 1;
			if (loginFailureCount >= setting.getAccountLockCount()) {
				admin.setIsLocked(true);
				admin.setLockedDate(new Date());
			}
			admin.setLoginFailureCount(loginFailureCount);
			adminService.update(admin);
			throw new IncorrectCredentialsException();
		}
		admin.setLoginIp(ip);
		admin.setLoginDate(new Date());
		admin.setLoginFailureCount(0);
		adminService.update(admin);
		return new SimpleAuthenticationInfo(new Principal(admin.getId(), username), password, getName());
	}
	throw new UnknownAccountException();
}
 
開發者ID:justinbaby,項目名稱:my-paper,代碼行數:69,代碼來源:AuthenticationRealm.java

示例7: createToken

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
private String createToken()
{
    Date validDate = DateUtils.addMinutes( new Date( System.currentTimeMillis() ), 3 );

    return TokenUtil.createToken(  getHeader(), getClaims("TestToken",validDate ) ,tokenSecret);
}
 
開發者ID:subutai-io,項目名稱:base,代碼行數:7,代碼來源:TokenUtilTest.java

示例8: createUserToken

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
 * ***********************************************************************************
 * Create JSON Web Token and save in DB
 *
 * @param user input String
 *
 * @return JSON Token
 */
@RolesAllowed( "Identity-Management|Write" )
@Override
public UserToken createUserToken( User user, String token, String secret, String issuer, int tokenType,
                                  Date validDate )
{
    try
    {
        UserToken userToken = new UserTokenEntity();

        if ( Strings.isNullOrEmpty( token ) )
        {
            token = UUID.randomUUID().toString();
        }
        if ( Strings.isNullOrEmpty( issuer ) )
        {
            issuer = "io.subutai";
        }
        if ( Strings.isNullOrEmpty( secret ) )
        {
            secret = UUID.randomUUID().toString();
        }
        if ( validDate == null )
        {
            validDate = DateUtils
                    .addMinutes( new Date( System.currentTimeMillis() ), sessionManager.getSessionTimeout() );
        }

        userToken.setTokenId( token );
        userToken.setHashAlgorithm( "HS256" );
        userToken.setIssuer( issuer );
        userToken.setSecret( secret );
        userToken.setUserId( user.getId() );
        userToken.setType( tokenType );
        userToken.setValidDate( validDate );

        identityDataService.persistUserToken( userToken );

        return userToken;
    }
    catch ( Exception ex )
    {
        return null;
    }
}
 
開發者ID:subutai-io,項目名稱:base,代碼行數:53,代碼來源:IdentityManagerImpl.java

示例9: buildExpireTime

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
protected Date buildExpireTime()
{
    return DateUtils.addMinutes( new Date(), ALERT_LIVE_TIME );
}
 
開發者ID:subutai-io,項目名稱:base,代碼行數:5,代碼來源:MonitorImpl.java

示例10: addMinutes

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
 * 給指定日期加幾分鍾
 * 
 * @param date
 *            指定的日期
 * @param numMins
 *            需要往後加的分鍾數
 * @return 加好後的日期
 */
public static Date addMinutes(Date date, int numMins) {
	Assert.notNull(date);
	return DateUtils.addMinutes(date, numMins);
}
 
開發者ID:thinking-github,項目名稱:nbone,代碼行數:14,代碼來源:DateUtil.java


注:本文中的org.apache.commons.lang.time.DateUtils.addMinutes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。