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


Java DateUtils.MILLIS_PER_DAY屬性代碼示例

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


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

示例1: moveForward

/**
 * Advance the cursor with the given duration.
 * 
 * @param duration
 *            Duration to add to current date. Business hours are considered.
 * @return The new date.
 */
public Date moveForward(final long duration) {
	long remainingDuration = duration;
	while (remainingDuration > 0) {
		this.delta = 0;

		// We need to move the cursors
		if (cursorTime + remainingDuration < DateUtils.MILLIS_PER_DAY) {
			// We need to compute the elapsed ranges and hours within the same day
			computeDelayTodayToTime(cursorTime + remainingDuration);
		} else {
			// Move to the end of this day
			computeDelayTodayToTime(DateUtils.MILLIS_PER_DAY);
		}
		remainingDuration -= delta;
	}

	// Return the new date
	return new Date(cursor.getTime() + getCursorTime());
}
 
開發者ID:ligoj,項目名稱:plugin-bt,代碼行數:26,代碼來源:ComputationContext.java

示例2: moveForwardPerformance

@Test(timeout = 2000)
public void moveForwardPerformance() {
	final List<Date> holidays = new ArrayList<>();
	holidays.add(getDate(2014, 03, 04));
	holidays.add(getDate(2014, 03, 06));
	for (int year = 2014; year < 2050; year++) {
		holidays.add(getDate(year, 03, 10));
	}
	final ComputationContext context = new ComputationContext(holidays, newRanges(9, 12, 14, 18));
	Date lastDate = getDate(2014, 03, 03);
	final List<Date> dates = new ArrayList<>();
	context.reset(lastDate);
	final Random random = new Random(1);
	for (int i = 10000; i-- > 0;) {
		final long increment = 2500 + (long) ((2 * DateUtils.MILLIS_PER_DAY - 50) * random.nextDouble());
		final Date newDate = new Date(lastDate.getTime() + increment);
		dates.add(newDate);
		lastDate = newDate;
	}
	long delta = 0;
	for (final Date date : dates) {
		delta += context.moveForward(date);
	}
	Assert.assertEquals(180633600000L, delta);
}
 
開發者ID:ligoj,項目名稱:plugin-bt,代碼行數:25,代碼來源:ComputationContextTest.java

示例3: genCert

public static X509Certificate genCert(KeyPair keyPair) throws NoSuchAlgorithmException, CertificateEncodingException, NoSuchProviderException, InvalidKeyException, SignatureException {
    Date startDate = new Date();              // time from which certificate is valid
    Date expiryDate = new Date(System.currentTimeMillis() + DateUtils.MILLIS_PER_DAY * 365);             // time after which certificate is not valid
    BigInteger serialNumber = BigInteger.ONE;     // serial number for certificate
    X509V1CertificateGenerator certGen = new X509V1CertificateGenerator();
    X500Principal dnName = new X500Principal("CN=Test CA Certificate");
    certGen.setSerialNumber(serialNumber);
    certGen.setIssuerDN(dnName);
    certGen.setNotBefore(startDate);
    certGen.setNotAfter(expiryDate);
    certGen.setSubjectDN(dnName);                       // note: same as issuer
    certGen.setPublicKey(keyPair.getPublic());
    certGen.setSignatureAlgorithm("SHA256WITHECDSA");
    return certGen.generate(keyPair.getPrivate(), "BC");    
}
 
開發者ID:papyrusglobal,項目名稱:state-channels,代碼行數:15,代碼來源:CryptoUtil.java

示例4: loadUserByUsername

@Override
public UserDetails loadUserByUsername(final String username) {
	final Object[][] userAndRoles = userRepository.findByLoginFetchRoles(username);
	final SystemUser user;
	final Collection<GrantedAuthority> authorities;
	if (userAndRoles.length == 0) {
		user = new SystemUser();
		user.setLogin(username);
		authorities = new ArrayList<>();
	} else {
		user = (SystemUser) userAndRoles[0][0];

		// Add all roles
		authorities = toSimpleRoles(userAndRoles, 1);
	}

	// Update last connection information only as needed for performance, delta is one minute
	final Date now = org.ligoj.bootstrap.core.DateUtils.newCalendar().getTime();
	if (user.getLastConnection() == null || now.getTime() - user.getLastConnection().getTime() > DateUtils.MILLIS_PER_DAY) {
		user.setLastConnection(now);
		userRepository.saveAndFlush(user);
	}

	// Also add the default role as needed
	authorities.add(new SimpleGrantedAuthority(SystemRole.DEFAULT_ROLE));
	return new User(username, "N/A", authorities);
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:27,代碼來源:RbacUserDetailsService.java

示例5: isFinished

/**
 * Is the current task is finished.
 */
private boolean isFinished(final BatchTaskVo<?> task) {
	return task.getStatus().getEnd() != null && task.getStatus().getEnd().getTime() + DateUtils.MILLIS_PER_DAY < System.currentTimeMillis();
}
 
開發者ID:ligoj,項目名稱:plugin-id,代碼行數:6,代碼來源:AbstractBatchResource.java


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