Java Code Examples for java.util.Date#before()
The following examples show how to use
java.util.Date#before() .
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: RedhatHandler.java From neoscada with Eclipse Public License 1.0 | 6 votes |
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$ }
Example 2
Source File: IntervalTrigger.java From kogito-runtimes with Apache License 2.0 | 6 votes |
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(); }
Example 3
Source File: X509CertificateShortInfoView.java From oxTrust with MIT License | 6 votes |
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); } }
Example 4
Source File: CustomLicenseManager.java From LicenseDemo with Apache License 2.0 | 6 votes |
/** * 校验生成证书的参数信息 * @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("用户类型不能为空"); } }
Example 5
Source File: ProjectBrokerManagerImpl.java From olat with Apache License 2.0 | 6 votes |
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; }
Example 6
Source File: TimeUtils.java From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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; }
Example 7
Source File: DefaultBatchWindowManager.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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; }
Example 8
Source File: SubmitFilesService.java From lams with GNU General Public License v2.0 | 5 votes |
@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); } }
Example 9
Source File: MobileMessagingCore.java From mobile-messaging-sdk-android with Apache License 2.0 | 5 votes |
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; }
Example 10
Source File: SignatureValidationContext.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
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; }
Example 11
Source File: FilePackageAction.java From bbs with GNU Affero General Public License v3.0 | 5 votes |
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; } }
Example 12
Source File: DateTime.java From org.openntf.domino with Apache License 2.0 | 5 votes |
@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); }
Example 13
Source File: AutoDisapproveDocumentsServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * 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; }
Example 14
Source File: SpigotLoginListenerPlay.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
private static boolean hasExpired(ExpirableListEntry<?> entry) { Date expireDate = entry.getExpires(); return (expireDate != null) && expireDate.before(new Date()); }
Example 15
Source File: DViewCRL.java From portecle with GNU General Public License v2.0 | 4 votes |
/** * 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); } }
Example 16
Source File: JwtTokenUtil.java From mall-learning with Apache License 2.0 | 4 votes |
/** * 判断token是否已经失效 */ private boolean isTokenExpired(String token) { Date expiredDate = getExpiredDateFromToken(token); return expiredDate.before(new Date()); }
Example 17
Source File: EventAction.java From unitime with Apache License 2.0 | 4 votes |
@Override public boolean isOutside(Date date) { return date == null || (iBegin != null && date.before(iBegin)) || (iEnd != null && !date.before(iEnd)); }
Example 18
Source File: JwtTokenUtil.java From spring-security-mybatis-demo with Apache License 2.0 | 4 votes |
private Boolean isTokenExpired(String token) { final Date expiration = getExpirationDateFromToken(token); return expiration.before(clock.now()); }
Example 19
Source File: BeanValidation.java From open-Autoscaler with Apache License 2.0 | 4 votes |
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; }
Example 20
Source File: DateRange.java From org.openntf.domino with Apache License 2.0 | 4 votes |
@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)); }