List of usage examples for java.util Date equals
public boolean equals(Object obj)
From source file:com.virtusa.akura.student.controller.StudentAcademicLifeController.java
/** * Method to validate studentPrefect types. * /*from ww w .j a v a 2 s . c o m*/ * @param studentId - student id defined by integer type variable. * @param intpTypeId prefect type id defined by an integer. * @param year - year which holding the prefect details defined by Date type variable. * @return boolean value indicating the validation status * @throws AkuraAppException throws when error occurs */ private boolean valiatePrefect(int studentId, int intpTypeId, Date year) throws AkuraAppException { boolean flag = false; List<StudentPrefect> stPreList = studentService.getAllStudentPrefectDetails(); Iterator<StudentPrefect> itr = stPreList.iterator(); while (itr.hasNext()) { StudentPrefect stPre = (StudentPrefect) itr.next(); int preTypeId = stPre.getPrefectType().getPrefectTypeId(); Date yearNew = stPre.getYear(); int studentNewId = stPre.getStudent().getStudentId(); if (preTypeId == intpTypeId && year.equals(yearNew) && studentId == studentNewId) { flag = true; } } return flag; }
From source file:service.actions.OrderSearch.java
private boolean todayOrLater(Date date) { Date current = new Date(); current = DateUtils.startOfDay(current); return (date.equals(current) || date.after(current)); }
From source file:org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.source.WfsFilterDelegateTest.java
/** * If the WFS server does not support an 'After' and 'Before' temporal query, and supports a * 'During' temporal query, the query should be translated into 'During <after> to <before>' *///from w w w.j ava2 s . c o m @Test public void testAbsoluteTemporalOnlyQueryDuringSupported() { setupMockMetacardType(); FilterType afterFilter = setupAfterFilterType(); FilterType beforeFilter = setupBeforeFilterType(); FilterCapabilities duringFilterCapabilities = setupFilterCapabilities(); WfsFilterDelegate duringDelegate = new WfsFilterDelegate(mockFeatureMetacardType, duringFilterCapabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER); // Get After Filter Date BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) afterFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); TimeInstantType timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); TimePositionType beginPositionType = timePeriod.getTimePosition(); Date afterDate = timePositionTypeToDate(beginPositionType); // Get Before Filter Date binaryTemporalOpType = (BinaryTemporalOpType) beforeFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); TimePositionType endPositionType = timePeriod.getTimePosition(); Date beforeDate = timePositionTypeToDate(endPositionType); List<FilterType> testFilters = new ArrayList<>(); testFilters.add(afterFilter); testFilters.add(beforeFilter); List<FilterType> convertedFilters = duringDelegate.applyTemporalFallbacks(testFilters); FilterType duringFilter = convertedFilters.get(0); assertThat(duringFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}During")); binaryTemporalOpType = (BinaryTemporalOpType) duringFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); TimePeriodType timePeriodType = (TimePeriodType) binaryTemporalOpType.getExpression().getValue(); beginPositionType = timePeriodType.getBeginPosition(); Date beginDate = timePositionTypeToDate(beginPositionType); endPositionType = timePeriodType.getEndPosition(); Date endDate = timePositionTypeToDate(endPositionType); // Verify Date range is created correctly assertThat(endDate.after(beginDate), is(true)); assertThat(endDate.equals(beforeDate), is(true)); assertThat(beginDate.equals(afterDate), is(true)); }
From source file:org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.source.WfsFilterDelegateTest.java
/** * If the WFS server does not support an 'After' and 'Before' temporal query, and supports a * 'During' temporal query, the query should be translated into 'During <after> to <before>' *///from w w w . j ava2 s .c om @Test public void testAbsoluteTemporalOnlyQueryDuringUnSupported() { setupMockMetacardType(); FilterType afterFilter = setupAfterFilterType(); FilterType beforeFilter = setupBeforeFilterType(); WfsFilterDelegate delegate = setupTemporalFilterDelegate(); // Get After Filter Date BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) afterFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); TimeInstantType timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); TimePositionType beginPositionType = timePeriod.getTimePosition(); Date afterDate = timePositionTypeToDate(beginPositionType); // Get Before Filter Date binaryTemporalOpType = (BinaryTemporalOpType) beforeFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); TimePositionType endPositionType = timePeriod.getTimePosition(); Date beforeDate = timePositionTypeToDate(endPositionType); List<FilterType> testFilters = new ArrayList<>(); testFilters.add(afterFilter); testFilters.add(beforeFilter); List<FilterType> convertedFilters = delegate.applyTemporalFallbacks(testFilters); FilterType resultAfterFilter = convertedFilters.get(0); FilterType resultBeforeFilter = convertedFilters.get(1); assertThat(resultAfterFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}After")); assertThat(resultBeforeFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}Before")); // Get Resulting After Filter Date binaryTemporalOpType = (BinaryTemporalOpType) resultAfterFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); TimeInstantType timePeriodType = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); beginPositionType = timePeriodType.getTimePosition(); Date beginDate = timePositionTypeToDate(beginPositionType); // Get Resulting Before Filter Date binaryTemporalOpType = (BinaryTemporalOpType) resultBeforeFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); timePeriodType = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); endPositionType = timePeriodType.getTimePosition(); Date endDate = timePositionTypeToDate(endPositionType); // Verify Date range is created correctly assertThat(endDate.after(beginDate), is(true)); assertThat(endDate.equals(beforeDate), is(true)); assertThat(beginDate.equals(afterDate), is(true)); }
From source file:com.instiwork.RegistrationActivity.java
public boolean isValidDOB(String dob) { try {/*from ww w . jav a 2 s. c o m*/ Calendar compareDate = Calendar.getInstance(); compareDate.add(compareDate.YEAR, -14); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); Date strDate = sdf.parse(dob); Date cDate = sdf.parse(sdf.format(compareDate.getTime())); if (cDate.after(strDate)) { return true; } else if (cDate.equals(strDate)) { return true; } else { return false; } } catch (Exception e) { Logger.showMessage(TAG, " DOB Exception : " + e.toString()); return false; } }
From source file:org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.source.TestWfsFilterDelegate.java
/** * If the WFS server does not support an 'After' and 'Before' temporal query, * and supports a 'During' temporal query, the query should be translated * into 'During <after> to <before>' *///from w ww. j a v a 2s. c om @Test public void testAbsoluteTemporalOnlyQueryDuringSupported() { setupMockMetacardType(); FilterType afterFilter = setupAfterFilterType(); FilterType beforeFilter = setupBeforeFilterType(); FilterCapabilities duringFilterCapabilities = setupFilterCapabilities(); WfsFilterDelegate duringDelegate = new WfsFilterDelegate(mockFeatureMetacardType, duringFilterCapabilities, Wfs20Constants.EPSG_4326_URN, mockMapper, WfsConstants.LAT_LON_ORDER); // Get After Filter Date BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) afterFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); TimeInstantType timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); TimePositionType beginPositionType = timePeriod.getTimePosition(); Date afterDate = timePositionTypeToDate(beginPositionType); // Get Before Filter Date binaryTemporalOpType = (BinaryTemporalOpType) beforeFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); TimePositionType endPositionType = timePeriod.getTimePosition(); Date beforeDate = timePositionTypeToDate(endPositionType); List<FilterType> testFilters = new ArrayList<>(); testFilters.add(afterFilter); testFilters.add(beforeFilter); List<FilterType> convertedFilters = duringDelegate.applyTemporalFallbacks(testFilters); FilterType duringFilter = convertedFilters.get(0); assertThat(duringFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}During")); binaryTemporalOpType = (BinaryTemporalOpType) duringFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); TimePeriodType timePeriodType = (TimePeriodType) binaryTemporalOpType.getExpression().getValue(); beginPositionType = timePeriodType.getBeginPosition(); Date beginDate = timePositionTypeToDate(beginPositionType); endPositionType = timePeriodType.getEndPosition(); Date endDate = timePositionTypeToDate(endPositionType); // Verify Date range is created correctly assertThat(endDate.after(beginDate), is(true)); assertThat(endDate.equals(beforeDate), is(true)); assertThat(beginDate.equals(afterDate), is(true)); }
From source file:org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.source.TestWfsFilterDelegate.java
/** * If the WFS server does not support an 'After' and 'Before' temporal query, * and supports a 'During' temporal query, the query should be translated * into 'During <after> to <before>' *///w ww . j a v a 2 s.c o m @Test public void testAbsoluteTemporalOnlyQueryDuringUnSupported() { setupMockMetacardType(); FilterType afterFilter = setupAfterFilterType(); FilterType beforeFilter = setupBeforeFilterType(); WfsFilterDelegate delegate = setupTemporalFilterDelegate(); // Get After Filter Date BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) afterFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); TimeInstantType timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); TimePositionType beginPositionType = timePeriod.getTimePosition(); Date afterDate = timePositionTypeToDate(beginPositionType); // Get Before Filter Date binaryTemporalOpType = (BinaryTemporalOpType) beforeFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); TimePositionType endPositionType = timePeriod.getTimePosition(); Date beforeDate = timePositionTypeToDate(endPositionType); List<FilterType> testFilters = new ArrayList<>(); testFilters.add(afterFilter); testFilters.add(beforeFilter); List<FilterType> convertedFilters = delegate.applyTemporalFallbacks(testFilters); FilterType resultAfterFilter = convertedFilters.get(0); FilterType resultBeforeFilter = convertedFilters.get(1); assertThat(resultAfterFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}After")); assertThat(resultBeforeFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}Before")); // Get Resulting After Filter Date binaryTemporalOpType = (BinaryTemporalOpType) resultAfterFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); TimeInstantType timePeriodType = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); beginPositionType = timePeriodType.getTimePosition(); Date beginDate = timePositionTypeToDate(beginPositionType); // Get Resulting Before Filter Date binaryTemporalOpType = (BinaryTemporalOpType) resultBeforeFilter.getTemporalOps().getValue(); assertThat(binaryTemporalOpType.isSetValueReference(), is(true)); assertThat(binaryTemporalOpType.isSetExpression(), is(true)); timePeriodType = (TimeInstantType) binaryTemporalOpType.getExpression().getValue(); endPositionType = timePeriodType.getTimePosition(); Date endDate = timePositionTypeToDate(endPositionType); // Verify Date range is created correctly assertThat(endDate.after(beginDate), is(true)); assertThat(endDate.equals(beforeDate), is(true)); assertThat(beginDate.equals(afterDate), is(true)); }
From source file:org.linagora.linshare.core.service.impl.UploadRequestServiceImpl.java
/** * Check if the current input date is after now and not before now more the * functionality duration if delegation policy allowed it. * now() < currentDate < now() + func.value * Otherwise functionality value is used as default value. * @param func/*ww w. j a v a 2s .c om*/ * @param currentDate * @return the proper date is returned according to activation policy, * configuration policy and others checks. */ private Date checkDate(TimeUnitValueFunctionality func, Date currentDate) { if (func.getActivationPolicy().getStatus()) { logger.debug(func.getIdentifier() + " is activated"); Calendar c = new GregorianCalendar(); c.add(func.toCalendarValue(), func.getValue()); Date maxDate = c.getTime(); if (func.getDelegationPolicy() != null && func.getDelegationPolicy().getStatus()) { logger.debug(func.getIdentifier() + " has a delegation policy"); if (currentDate != null) { if (currentDate.after(maxDate) || currentDate.before(new Date())) { logger.warn("the current value " + currentDate.toString() + " is out of range : " + func.toString() + " : " + maxDate.toString()); return maxDate; } else { return currentDate; } } return maxDate; } else { // there is no delegation, the current value should be the // system value or null logger.debug(func.getIdentifier() + " does not have a delegation policy"); if (currentDate != null) { if (!currentDate.equals(maxDate)) { logger.warn("the current value " + currentDate.toString() + " is different than system value " + maxDate); } } return maxDate; } } else { logger.debug(func.getIdentifier() + " is not activated"); if (currentDate != null) { logger.warn("the current value " + currentDate.toString() + " should be null for the functionality " + func.toString()); } return null; } }
From source file:com.novemberain.quartz.mongodb.MongoDBJobStore.java
protected boolean applyMisfire(OperableTrigger trigger) throws JobPersistenceException { long misfireTime = System.currentTimeMillis(); if (getMisfireThreshold() > 0) { misfireTime -= getMisfireThreshold(); }// w w w . j a v a 2 s . c o m Date tnft = trigger.getNextFireTime(); if (tnft == null || tnft.getTime() > misfireTime || trigger.getMisfireInstruction() == Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY) { return false; } Calendar cal = null; if (trigger.getCalendarName() != null) { cal = retrieveCalendar(trigger.getCalendarName()); } signaler.notifyTriggerListenersMisfired((OperableTrigger) trigger.clone()); trigger.updateAfterMisfire(cal); if (trigger.getNextFireTime() == null) { signaler.notifySchedulerListenersFinalized(trigger); } else if (tnft.equals(trigger.getNextFireTime())) { return false; } storeTrigger(trigger, true); return true; }
From source file:edu.stanford.muse.index.IndexUtils.java
/** returns list of list of docs organized by a series of time windows */ public static List<Window> docsBySlidingWindow(Collection<EmailDocument> allDocs, int windowSizeInMonths, int stepSizeInMonths) { List<Window> result = new ArrayList<Window>(); if (allDocs.size() == 0) return result; // compute the begin and end date of the corpus Date first = null;//ww w. j a va 2 s . c o m Date last = null; for (EmailDocument ed : allDocs) { Date d = ed.date; if (d == null) { // drop this ed log.warn("Warning: null date on email: " + ed.getHeader()); continue; } if (first == null || d.before(first)) first = d; if (last == null || d.after(last)) last = d; } // compute the monthly intervals List<Pair<Date, Date>> intervals = Util.getSlidingMonthlyIntervalsBackward(first, last, windowSizeInMonths, stepSizeInMonths); int nIntervals = intervals.size(); for (int i = 0; i < nIntervals; i++) { Window w = new Window(); w.start = intervals.get(i).getFirst(); w.end = intervals.get(i).getSecond(); w.docs = new ArrayList<EmailDocument>(); result.add(w); } // for each message, add it to all intervals it belongs to // can be made more efficient by first sorting allDocs by date etc // but may not be needed except for a very large # of intervals and // a large # of docs for (EmailDocument ed : allDocs) { Date d = ed.date; if (d == null) continue; // add ed to all intervals that c falls in for (int i = 0; i < nIntervals; i++) { Pair<Date, Date> interval = intervals.get(i); Date intervalStart = interval.getFirst(); Date intervalEnd = interval.getSecond(); if (d.equals(intervalStart) || d.equals(intervalEnd) || (d.after(intervalStart) && d.before(intervalEnd))) { result.get(i).docs.add(ed); break; } } } return result; }