java.util.Date#before ( )源码实例Demo

下面列出了java.util.Date#before ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: neoscada   文件: RedhatHandler.java
private String makeVersion ( final List<ChangeEntry> changes )
{
    String version = null;
    Date date = null;

    for ( final ChangeEntry entry : changes )
    {
        if ( date == null || date.before ( entry.getDate () ) )
        {
            date = entry.getDate ();
            version = entry.getVersion ();
        }
    }

    return version == null ? "0.0.0" : version; //$NON-NLS-1$
}
 
源代码2 项目: LicenseDemo   文件: CustomLicenseManager.java
/**
 * 校验生成证书的参数信息
 * @author zifangsky
 * @date 2018/5/2 15:43
 * @since 1.0.0
 * @param content 证书正文
 */
protected synchronized void validateCreate(final LicenseContent content)
        throws LicenseContentException {
    final LicenseParam param = getLicenseParam();

    final Date now = new Date();
    final Date notBefore = content.getNotBefore();
    final Date notAfter = content.getNotAfter();
    if (null != notAfter && now.after(notAfter)){
        throw new LicenseContentException("证书失效时间不能早于当前时间");
    }
    if (null != notBefore && null != notAfter && notAfter.before(notBefore)){
        throw new LicenseContentException("证书生效时间不能晚于证书失效时间");
    }
    final String consumerType = content.getConsumerType();
    if (null == consumerType){
        throw new LicenseContentException("用户类型不能为空");
    }
}
 
源代码3 项目: olat   文件: ProjectBrokerManagerImpl.java
public boolean isDropboxAccessible(final Project project, final ProjectBrokerModuleConfiguration moduleConfig) {
    if (moduleConfig.isProjectEventEnabled(EventType.HANDOUT_EVENT)) {
        final ProjectEvent handoutEvent = project.getProjectEvent(EventType.HANDOUT_EVENT);
        final Date now = new Date();
        if (handoutEvent.getStartDate() != null) {
            if (now.before(handoutEvent.getStartDate())) {
                return false;
            }
        }
        if (handoutEvent.getEndDate() != null) {
            if (now.after(handoutEvent.getEndDate())) {
                return false;
            }
        }
    }
    return true;
}
 
@Override
public BatchWindow getCurrentOrNextBatchWindow(Date date, ProcessEngineConfigurationImpl configuration) {
  final BatchWindow previousDayBatchWindow = getPreviousDayBatchWindow(date, configuration);
  if (previousDayBatchWindow != null && previousDayBatchWindow.isWithin(date)) {
    return previousDayBatchWindow;
  }

  final BatchWindow currentDayBatchWindow = getBatchWindowForDate(date, configuration);
  if (currentDayBatchWindow!= null && (currentDayBatchWindow.isWithin(date) || date.before(currentDayBatchWindow.getStart()))) {
    return currentDayBatchWindow;
  }

  //check next week
  for (int i=1; i<=7; i++ ) {
    Date dateToCheck = addDays(date, i);
    final BatchWindow batchWindowForDate = getBatchWindowForDate(dateToCheck, configuration);
    if (batchWindowForDate != null) {
      return batchWindowForDate;
    }
  }

  return null;
}
 
源代码5 项目: DisCal-Discord-Bot   文件: TimeUtils.java
/**
 * Checks whether or not the end date is before the start date of the event.
 *
 * @param endRaw   The date to check in format (yyyy/MM/dd-HH:mm:ss).
 * @param timezone The timezone of the calendar this event is for.
 * @param event    The event that is currently being created.
 * @return <code>true</code> if the end is before the start, otherwise <code>false</code>.
 */
public static boolean endBeforeStart(String endRaw, TimeZone timezone, PreEvent event) {
	if (event.getStartDateTime() != null) {
		try {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss");
			sdf.setTimeZone(timezone);
			Date endDate = sdf.parse(endRaw);
			Date startDate = new Date(event.getStartDateTime().getDateTime().getValue());

			return endDate.before(startDate);
		} catch (ParseException e) {
			return true;
		}
	}
	return false;
}
 
源代码6 项目: oxTrust   文件: X509CertificateShortInfoView.java
public final void updateViewStyle() {
    final Date currentTime = new Date();
    final Date time3MonthAfter = new Date(System.currentTimeMillis() + NANOSEC_3_MONTH);
    
    // check dates
    if (currentTime.after(getNotAfterDatetime())) {
        setViewStyle(HIGHLIGHT_STYLE_UNVALID);// expired
        warning = true;
    } else if (getNotBeforeDatetime().after(getNotAfterDatetime())) {
        setViewStyle(HIGHLIGHT_STYLE_UNVALID);// error in certificate
        warning = true;
    } else if (currentTime.before(getNotBeforeDatetime())) {
        setViewStyle(HIGHLIGHT_STYLE_WARNING);
        warning = true;
    } else if (time3MonthAfter.after(getNotAfterDatetime())) {
        setViewStyle(HIGHLIGHT_STYLE_UNVALID);// 3 month before expiration
        warning = true;
    } else {
        setViewStyle(HIGHLIGHT_STYLE_VALID);
    }
}
 
源代码7 项目: kogito-runtimes   文件: IntervalTrigger.java
public void setStartTime(Date startTime) {
    if ( startTime == null ) {
        throw new IllegalArgumentException( "Start time cannot be null" );
    }

    Date eTime = getEndTime();
    if ( eTime != null && eTime.before( startTime ) ) {
        throw new IllegalArgumentException( "End time cannot be before start time" );
    }

    // round off millisecond...
    // Note timeZone is not needed here as parameter for
    // Calendar.getInstance(),
    // since time zone is implicit when using a Date in the setTime method.
    Calendar cl = Calendar.getInstance();
    cl.setTime( startTime );

    this.startTime = cl.getTime();
}
 
源代码8 项目: bbs   文件: FilePackageAction.java
public int compare(Object obj1, Object obj2) {  
    Date begin = ((FilePackage)obj1).getCreateTime();  
    Date end = ((FilePackage)obj2).getCreateTime();  
    if (begin.before(end)) {  
        return 1;  
    } else {  
        return -1;  
    }  
}
 
源代码9 项目: dss   文件: SignatureValidationContext.java
private Date getEarliestTimestampTime() {
	Date earliestDate = null;
	for (TimestampToken timestamp : getProcessedTimestamps()) {
		if (timestamp.getTimeStampType().coversSignature()) {
			Date timestampTime = timestamp.getCreationDate();
			if (earliestDate == null || timestampTime.before(earliestDate)) {
				earliestDate = timestampTime;
			}
		}
	}
	return earliestDate;
}
 
源代码10 项目: org.openntf.domino   文件: DateTime.java
@Override
public boolean isBeforeIgnoreDate(final org.openntf.domino.DateTime compareDate) {
	Calendar cal = calendar.get();
	cal.setTime(date_);
	cal.set(Calendar.DAY_OF_MONTH, 1);
	cal.set(Calendar.MONTH, 0);
	cal.set(Calendar.YEAR, 2000);
	Date d1 = cal.getTime();
	cal.setTime(compareDate.toJavaDate());
	cal.set(Calendar.DAY_OF_MONTH, 1);
	cal.set(Calendar.MONTH, 0);
	cal.set(Calendar.YEAR, 2000);
	Date d2 = cal.getTime();
	return d1.before(d2);
}
 
源代码11 项目: kfs   文件: AutoDisapproveDocumentsServiceImpl.java
/**
 * This method first checks the document's create date with system parameter date and then
 * checks the document type name to the system parameter values and returns true if the type name exists
 * @param document document to check for its document type,  documentCompareDate the system parameter specified date
 * to compare the current date to this date.
 * @return true if  document's create date is <= documentCompareDate and if document type is not in the
 * system parameter document types that are set to disallow.
 */
protected boolean exceptionsToAutoDisapproveProcess(DocumentHeader documentHeader, Date documentCompareDate) {
    boolean exceptionToDisapprove = true;
    Date createDate = null;

    String documentNumber =  documentHeader.getDocumentNumber();

    DateTime documentCreateDate = documentHeader.getWorkflowDocument().getDateCreated();
    createDate = documentCreateDate.toDate();

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(documentCompareDate);
    String strCompareDate = calendar.getTime().toString();

    calendar.setTime(createDate);
    String strCreateDate = calendar.getTime().toString();

    if (createDate.before(documentCompareDate) || createDate.equals(documentCompareDate)) {
        String documentTypeName = documentHeader.getWorkflowDocument().getDocumentTypeName();

        ParameterEvaluator evaluatorDocumentType = /*REFACTORME*/SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(AutoDisapproveDocumentsStep.class, KFSParameterKeyConstants.YearEndAutoDisapprovalConstants.YEAR_END_AUTO_DISAPPROVE_DOCUMENT_TYPES, documentTypeName);
        exceptionToDisapprove = !evaluatorDocumentType.evaluationSucceeds();
        if (exceptionToDisapprove) {
            LOG.info("Document Id: " + documentNumber + " - Exception to Auto Disapprove:  Document's type: " + documentTypeName + " is in the System Parameter For Document Types Exception List.");
        }
    }
    else {
        LOG.info("Document Id: " + documentNumber + " - Exception to Auto Disapprove:  Document's create date: " + strCreateDate + " is NOT less than or equal to System Parameter Compare Date: " + strCompareDate);
        exceptionToDisapprove = true;
    }

    return exceptionToDisapprove;
}
 
private boolean areInstallationsExpired() {
    Date now = Time.date();
    long expiryTimestamp = PreferenceHelper.findLong(context, MobileMessagingProperty.USER_INSTALLATIONS_EXPIRE_AT);
    if (expiryTimestamp != 0) {
        Date expiryDate = new Date(expiryTimestamp);
        return expiryDate.before(now);
    }
    return false;
}
 
源代码13 项目: lams   文件: SubmitFilesService.java
@Override
   public ToolCompletionStatus getCompletionStatus(Long learnerId, Long toolSessionId) {
SubmitUser learner = getSessionUser(toolSessionId, learnerId.intValue());
if (learner == null) {
    return new ToolCompletionStatus(ToolCompletionStatus.ACTIVITY_NOT_ATTEMPTED, null, null);
}

Date startDate = null;
Date endDate = null;
List<SubmissionDetails> list = submissionDetailsDAO.getBySessionAndLearner(toolSessionId, learnerId.intValue());
for (SubmissionDetails detail : list) {
    Date newDate = detail.getDateOfSubmission();
    if (newDate != null) {
	if (startDate == null || newDate.before(startDate)) {
	    startDate = newDate;
	}
	if (endDate == null || newDate.after(endDate)) {
	    endDate = newDate;
	}
    }
}

if (learner.isFinished()) {
    return new ToolCompletionStatus(ToolCompletionStatus.ACTIVITY_COMPLETED, startDate, endDate);
} else {
    return new ToolCompletionStatus(ToolCompletionStatus.ACTIVITY_ATTEMPTED, startDate, null);
}
   }
 
源代码14 项目: org.openntf.domino   文件: DateRange.java
@Override
public boolean contains(final Date date) {
	Date start = this.getStartDateTime().toJavaDate();
	Date end = this.getEndDateTime().toJavaDate();
	return (date.equals(start) || date.after(start)) && (date.equals(end) || date.before(end));
}
 
源代码15 项目: open-Autoscaler   文件: BeanValidation.java
public int compare(Map<String, String> first,
                   Map<String, String> second)
{
    // TODO: Null checking, both for maps and values
	if ((first == null) && (second == null))
		return 0;
	if (first == null)
		throw new RuntimeException("first object is null in DateTimeComparator");
	if (second == null)
		throw new RuntimeException("second object is null in DateTimeComparator");
	
    String firstValue_key1 = first.get(key1);
    String firstValue_key2 = first.get(key2);
    String secondValue_key1 = second.get(key1);
    String secondValue_key2 = second.get(key2);
    
    if ((firstValue_key1 == null) || (firstValue_key2 == null))
		throw new RuntimeException("firstValue is null in DateTimeComparator");
    if ((secondValue_key1 == null) || (secondValue_key2 == null))
		throw new RuntimeException("secondValue is null in CommonComparator");
    
    if(keyType.equals("DateTime")){ //assume date in key1 and time in key2

    	SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    	dateformat.setLenient(false);
     	String firstDateTime = firstValue_key1 + " " + firstValue_key2;
     	String secondDateTime = secondValue_key1 + " " + secondValue_key2;
     	ParsePosition position = new ParsePosition(0);
     	Date firstdate = dateformat.parse(firstDateTime, position);
     	if (( firstdate == null) || (position.getIndex() != firstDateTime.length()))
     		return -2;
     	position = new ParsePosition(0);
     	Date seconddate = dateformat.parse(secondDateTime, position);
     	if (( seconddate == null) || (position.getIndex() != secondDateTime.length()))
     		return -2;
     	try {
      	if(firstdate.before(seconddate))
      		return -1;
      	else if (firstdate.equals(seconddate))
      		return 0;
      	else
      		return 1;
     	} catch (Exception e){
     		return -2;
     	}
    }

    return -2;
}
 
private Boolean isTokenExpired(String token) {
    final Date expiration = getExpirationDateFromToken(token);
    return expiration.before(clock.now());
}
 
源代码17 项目: unitime   文件: EventAction.java
@Override
public boolean isOutside(Date date) {
	return date == null || (iBegin != null && date.before(iBegin)) || (iEnd != null && !date.before(iEnd));
}
 
源代码18 项目: mall-learning   文件: JwtTokenUtil.java
/**
 * 判断token是否已经失效
 */
private boolean isTokenExpired(String token) {
    Date expiredDate = getExpiredDateFromToken(token);
    return expiredDate.before(new Date());
}
 
源代码19 项目: ProtocolSupport   文件: SpigotLoginListenerPlay.java
private static boolean hasExpired(ExpirableListEntry<?> entry) {
	Date expireDate = entry.getExpires();
	return (expireDate != null) && expireDate.before(new Date());
}
 
源代码20 项目: portecle   文件: DViewCRL.java
/**
 * Populate the dialog with the CRL's details.
 */
private void populateDialog()
{
	// Populate CRL fields:

	// Has the CRL [been issued/been updated]
	Date currentDate = new Date();

	Date effectiveDate = m_crl.getThisUpdate();

	boolean bEffective = currentDate.before(effectiveDate);

	// Version
	m_jtfVersion.setText(Integer.toString(m_crl.getVersion()));
	m_jtfVersion.setCaretPosition(0);

	// Issuer
	m_jtfIssuer.setText(m_crl.getIssuerDN().toString());
	m_jtfIssuer.setCaretPosition(0);

	// Effective Date (include time zone)
	m_jtfEffectiveDate.setText(
	    DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(effectiveDate));

	if (bEffective)
	{
		m_jtfEffectiveDate.setText(MessageFormat.format(
		    RB.getString("DViewCRL.m_jtfEffectiveDate.noteffective.text"), m_jtfEffectiveDate.getText()));
		m_jtfEffectiveDate.setForeground(Color.red);
	}
	else
	{
		m_jtfEffectiveDate.setForeground(m_jtfVersion.getForeground());
	}
	m_jtfEffectiveDate.setCaretPosition(0);

	// Next update
	Date updateDate = m_crl.getNextUpdate();
	if (updateDate != null)
	{
		m_jtfNextUpdate.setText(
		    DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(updateDate));

		if (currentDate.after(updateDate))
		{
			m_jtfNextUpdate.setText(MessageFormat.format(
			    RB.getString("DViewCRL.m_jtfNextUpdate.updateavailable.text"), m_jtfNextUpdate.getText()));
			m_jtfNextUpdate.setForeground(Color.red);
		}
		else
		{
			m_jtfNextUpdate.setForeground(m_jtfVersion.getForeground());
		}
	}
	else
	{
		m_jtfNextUpdate.setText(RB.getString("DViewCRL.m_jtfNextUpdate.notavailable.text"));
		m_jtfNextUpdate.setForeground(m_jtfVersion.getForeground());
		m_jtfNextUpdate.setEnabled(false);
	}
	m_jtfNextUpdate.setCaretPosition(0);

	// Signature Algorithm
	m_jtfSignatureAlgorithm.setText(m_crl.getSigAlgName());
	m_jtfSignatureAlgorithm.setCaretPosition(0);

	// Enable/disable extensions button
	Set<String> critExts = m_crl.getCriticalExtensionOIDs();
	Set<String> nonCritExts = m_crl.getNonCriticalExtensionOIDs();

	if ((critExts != null && !critExts.isEmpty()) || (nonCritExts != null && !nonCritExts.isEmpty()))
	{
		// Extensions
		m_jbCrlExtensions.setEnabled(true);
	}
	else
	{
		// No extensions
		m_jbCrlExtensions.setEnabled(false);
	}

	// Populate Revoked Certificates table
	Set<? extends X509CRLEntry> revokedCertsSet = m_crl.getRevokedCertificates();
	if (revokedCertsSet == null)
	{
		revokedCertsSet = Collections.emptySet();
	}

	X509CRLEntry[] revokedCerts = revokedCertsSet.toArray(new X509CRLEntry[revokedCertsSet.size()]);
	RevokedCertsTableModel revokedCertsTableModel = (RevokedCertsTableModel) m_jtRevokedCerts.getModel();
	revokedCertsTableModel.load(revokedCerts);

	// Select first CRL
	if (revokedCertsTableModel.getRowCount() > 0)
	{
		m_jtRevokedCerts.changeSelection(0, 0, false, false);
	}
}