Java Code Examples for org.joda.time.DateTime#isBefore()
The following examples show how to use
org.joda.time.DateTime#isBefore() .
These examples are extracted from open source projects.
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 Project: fenixedu-academic File: WrittenEvaluation.java License: GNU Lesser General Public License v3.0 | 6 votes |
private void checkEnrolmentDates(final Date enrolmentBeginDay, final Date enrolmentEndDay, final Date enrolmentBeginTime, final Date enrolmentEndTime) throws DomainException { final DateTime enrolmentBeginDate = createDate(enrolmentBeginDay, enrolmentBeginTime); final DateTime enrolmentEndDate = createDate(enrolmentEndDay, enrolmentEndTime); if (getEnrollmentBeginDayDate() == null && enrolmentBeginDate.isBeforeNow()) { throw new DomainException("error.beginDate.sooner.today"); } if (enrolmentEndDate.isBefore(enrolmentBeginDate)) { throw new DomainException("error.endDate.sooner.beginDate"); } if (getBeginningDateTime().isBefore(enrolmentEndDate)) { throw new DomainException("error.examDate.sooner.endDate"); } }
Example 2
Source Project: googleads-adxbuyer-examples File: CreateAccountLevelFilterSet.java License: Apache License 2.0 | 6 votes |
private AbsoluteDateRange buildAbsoluteDateRange(String startDate, String endDate) { DateTime s = df.parseDateTime(startDate); DateTime e = df.parseDateTime(endDate); if(e.isBefore(s.getMillis())) { throw new IllegalArgumentException("Error: The end date can not be before the start date."); } Date start = new Date(); start.setYear(s.getYear()); start.setMonth(s.getMonthOfYear()); start.setDay(s.getDayOfMonth()); Date end = new Date(); end.setYear(e.getYear()); end.setMonth(e.getMonthOfYear()); end.setDay(e.getDayOfMonth()); AbsoluteDateRange absoluteDateRange = new AbsoluteDateRange(); absoluteDateRange.setStartDate(start); absoluteDateRange.setEndDate(end); return absoluteDateRange; }
Example 3
Source Project: spork File: DateTimeMin.java License: Apache License 2.0 | 6 votes |
@Override public void accumulate(Tuple b) throws IOException { try { DateTime curMin = min(b); if (curMin == null) { return; } // check curMin if (intermediateMin == null || curMin.isBefore(intermediateMin)) { intermediateMin = curMin; } } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; String msg = "Error while computing min in " + this.getClass().getSimpleName(); throw new ExecException(msg, errCode, PigException.BUG, e); } }
Example 4
Source Project: fenixedu-academic File: CurricularCourse.java License: GNU Lesser General Public License v3.0 | 6 votes |
public Curriculum findLatestCurriculumModifiedBefore(Date date) { Curriculum latestCurriculum = null; for (Curriculum curriculum : getAssociatedCurriculumsSet()) { if (curriculum.getLastModificationDateDateTime().toDate().compareTo(date) == 1) { // modified after date continue; } if (latestCurriculum == null) { latestCurriculum = curriculum; continue; } DateTime currentLastModificationDate = latestCurriculum.getLastModificationDateDateTime(); if (currentLastModificationDate.isBefore(curriculum.getLastModificationDateDateTime())) { latestCurriculum = curriculum; } } return latestCurriculum; }
Example 5
Source Project: saml-client File: ValidatorUtils.java License: MIT License | 6 votes |
/** * Enforce conditions. * * @param conditions the conditions * @param _now the current date time (for unit test only) * @param notBeforeSkew the notBeforeSkew * @throws SamlException the saml exception */ private static void enforceConditions(Conditions conditions, DateTime _now, long notBeforeSkew) throws SamlException { DateTime now = _now != null ? _now : DateTime.now(); DateTime notBefore = conditions.getNotBefore(); DateTime skewedNotBefore = notBefore.minus(notBeforeSkew); if (now.isBefore(skewedNotBefore)) { throw new SamlException("The assertion cannot be used before " + notBefore.toString()); } DateTime notOnOrAfter = conditions.getNotOnOrAfter(); if (now.isAfter(notOnOrAfter)) { throw new SamlException("The assertion cannot be used after " + notOnOrAfter.toString()); } }
Example 6
Source Project: cron File: CronExpressionTest.java License: Apache License 2.0 | 6 votes |
@Test public void check_hour_shall_run_25_times_in_DST_change_to_wintertime() throws Exception { CronExpression cron = new CronExpression("0 1 * * * *"); DateTime start = new DateTime(2011, 10, 30, 0, 0, 0, 0); DateTime slutt = start.toLocalDate().plusDays(1).toDateTimeAtStartOfDay(); DateTime tid = start; assertThat(Hours.hoursBetween(start, slutt).getHours()).isEqualTo(25); int count=0; DateTime lastTime = tid; while(tid.isBefore(slutt)){ DateTime nextTime = cron.nextTimeAfter(tid); assertThat(nextTime.isAfter(lastTime)).isTrue(); lastTime = nextTime; tid = tid.plusHours(1); count++; } assertThat(count).isEqualTo(25); }
Example 7
Source Project: actframework File: CronExpressionTest.java License: Apache License 2.0 | 6 votes |
@Test public void check_hour_shall_run_25_times_in_DST_change_to_wintertime() throws Exception { CronExpression cron = new CronExpression("0 1 * * * *"); DateTime start = new DateTime(2011, 10, 30, 0, 0, 0, 0); DateTime slutt = start.toLocalDate().plusDays(1).toDateTimeAtStartOfDay(); DateTime tid = start; assertThat(Hours.hoursBetween(start, slutt).getHours()).isEqualTo(25); int count=0; DateTime lastTime = tid; while(tid.isBefore(slutt)){ DateTime nextTime = cron.nextTimeAfter(tid); assertThat(nextTime.isAfter(lastTime)).isTrue(); lastTime = nextTime; tid = tid.plusHours(1); count++; } assertThat(count).isEqualTo(25); }
Example 8
Source Project: conference-app File: Session.java License: MIT License | 5 votes |
/** * Method defines if session is near to be started or finished +/- 1 hour * * @param now * @return true if session will start in +/- 1 hour from now */ public boolean isInNearProgress(DateTime now) { DateTime startTime = DateTime.parse(this.date + " " + this.start, DateTimeFormat.forPattern("dd.MM.yyyy HH:mm")); DateTime beforeStart = now.minusHours(1); DateTime afterStart = now.plusHours(2); return ((startTime.isAfter(beforeStart) || startTime.isEqual(beforeStart)) && (startTime.isBefore(afterStart) || startTime.isEqual(afterStart))); }
Example 9
Source Project: MaxKey File: AbstractRemeberMeService.java License: Apache License 2.0 | 5 votes |
public boolean login(String remeberMe, HttpServletResponse response) { _logger.debug("RemeberMe : " + remeberMe); remeberMe = new String(Base64Utils.base64UrlDecode(remeberMe)); remeberMe = ReciprocalUtils.decoder(remeberMe); _logger.debug("decoder RemeberMe : " + remeberMe); RemeberMe remeberMeCookie = new RemeberMe(); remeberMeCookie = (RemeberMe) JsonUtils.json2Object(remeberMe, remeberMeCookie); _logger.debug("Remeber Me Cookie : " + remeberMeCookie); RemeberMe storeRemeberMe = read(remeberMeCookie); if (storeRemeberMe == null) { return false; } DateTime loginDate = new DateTime(storeRemeberMe.getLastLogin()); DateTime expiryDate = loginDate.plusSeconds(getRemeberMeValidity()); DateTime now = new DateTime(); if (now.isBefore(expiryDate)) { if (WebContext.setAuthentication( storeRemeberMe.getUsername(), ConstantsLoginType.REMEBER_ME, "", "", "success") ) { return updateRemeberMe(remeberMeCookie, response); } } return false; }
Example 10
Source Project: fenixedu-academic File: RefactoredIndividualCandidacyProcessPublicDA.java License: GNU Lesser General Public License v3.0 | 5 votes |
protected boolean isApplicationSubmissionPeriodValid() { CandidacyProcess process = getCurrentOpenParentProcess(); if (process == null) { return false; } DateTime now = new DateTime(System.currentTimeMillis()); return now.isAfter(process.getCandidacyStart()) && now.isBefore(process.getCandidacyEnd()); }
Example 11
Source Project: estatio File: PaymentBatch_complete.java License: Apache License 2.0 | 5 votes |
public String validate0Act(DateTime proposed) { if(proposed == null) { return null; } final DateTime now = clockService.nowAsDateTime(); return proposed.isBefore(now) ? "Requested execution date cannot be in the past" : null; }
Example 12
Source Project: lams File: EntityDescriptorImpl.java License: GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ public boolean isValid() { if (null == validUntil) { return true; } DateTime now = new DateTime(); return now.isBefore(validUntil); }
Example 13
Source Project: outlay File: DateUtils.java License: Apache License 2.0 | 5 votes |
public static boolean isInPeriod(Date date, Date start, Date end) { DateTime dateTime = new DateTime(date); DateTime startDate = new DateTime(start); DateTime endDate = new DateTime(end); return dateTime.isAfter(startDate) && dateTime.isBefore(endDate); }
Example 14
Source Project: incubator-pinot File: DimensionWrapper.java License: Apache License 2.0 | 5 votes |
public DimensionWrapper(DataProvider provider, DetectionConfigDTO config, long startTime, long endTime) { super(provider, config, startTime, endTime); // the metric used in dimension exploration this.metricUrn = MapUtils.getString(config.getProperties(), "metricUrn", null); this.minContribution = MapUtils.getDoubleValue(config.getProperties(), "minContribution", Double.NaN); this.minValue = MapUtils.getDoubleValue(config.getProperties(), "minValue", Double.NaN); this.minValueHourly = MapUtils.getDoubleValue(config.getProperties(), "minValueHourly", Double.NaN); this.maxValueHourly = MapUtils.getDoubleValue(config.getProperties(), "maxValueHourly", Double.NaN); this.minValueDaily = MapUtils.getDoubleValue(config.getProperties(), "minValueDaily", Double.NaN); this.maxValueDaily = MapUtils.getDoubleValue(config.getProperties(), "maxValueDaily", Double.NaN); this.k = MapUtils.getIntValue(config.getProperties(), "k", -1); this.dimensions = ConfigUtils.getList(config.getProperties().get("dimensions")); this.lookback = ConfigUtils.parsePeriod(MapUtils.getString(config.getProperties(), "lookback", "1w")); this.timezone = DateTimeZone.forID(MapUtils.getString(config.getProperties(), "timezone", "America/Los_Angeles")); /* * A bucket of the time series is taken into consider only if its value is above the minLiveZone. In other words, * if a bucket's value is smaller than minLiveZone, then this bucket is ignored when calculating the average value. * Used for outlier removal. Replace legacy average threshold filter. */ this.minLiveZone = MapUtils.getDoubleValue(config.getProperties(), "minLiveZone", Double.NaN); this.liveBucketPercentageThreshold = MapUtils.getDoubleValue(config.getProperties(), "liveBucketPercentageThreshold", 0.5); // the metric to run the detection for this.nestedMetricUrns = ConfigUtils.getList(config.getProperties().get(PROP_NESTED_METRIC_URNS), Collections.singletonList(this.metricUrn)); this.nestedMetricUrnKey = MapUtils.getString(config.getProperties(), PROP_NESTED_METRIC_URN_KEY, PROP_NESTED_METRIC_URN_KEY_DEFAULT); this.nestedProperties = ConfigUtils.getList(config.getProperties().get(PROP_NESTED)); this.start = new DateTime(this.startTime, this.timezone); this.end = new DateTime(this.endTime, this.timezone); DateTime minStart = this.end.minus(this.lookback); if (minStart.isBefore(this.start)) { this.start = minStart; } this.evaluationMetricUrns = new HashSet<>(); }
Example 15
Source Project: incubator-gobblin File: CompactionTimeRangeVerifier.java License: Apache License 2.0 | 5 votes |
public Result verify (FileSystemDataset dataset) { final DateTime earliest; final DateTime latest; try { CompactionPathParser.CompactionParserResult result = new CompactionPathParser(state).parse(dataset); DateTime folderTime = result.getTime(); DateTimeZone timeZone = DateTimeZone.forID(this.state.getProp(MRCompactor.COMPACTION_TIMEZONE, MRCompactor.DEFAULT_COMPACTION_TIMEZONE)); DateTime compactionStartTime = new DateTime(this.state.getPropAsLong(CompactionSource.COMPACTION_INIT_TIME), timeZone); PeriodFormatter formatter = new PeriodFormatterBuilder().appendMonths().appendSuffix("m").appendDays().appendSuffix("d").appendHours() .appendSuffix("h").toFormatter(); // Dataset name is like 'Identity/MemberAccount' or 'PageViewEvent' String datasetName = result.getDatasetName(); // get earliest time String maxTimeAgoStrList = this.state.getProp(TimeBasedSubDirDatasetsFinder.COMPACTION_TIMEBASED_MAX_TIME_AGO, TimeBasedSubDirDatasetsFinder.DEFAULT_COMPACTION_TIMEBASED_MAX_TIME_AGO); String maxTimeAgoStr = getMachedLookbackTime(datasetName, maxTimeAgoStrList, TimeBasedSubDirDatasetsFinder.DEFAULT_COMPACTION_TIMEBASED_MAX_TIME_AGO); Period maxTimeAgo = formatter.parsePeriod(maxTimeAgoStr); earliest = compactionStartTime.minus(maxTimeAgo); // get latest time String minTimeAgoStrList = this.state.getProp(TimeBasedSubDirDatasetsFinder.COMPACTION_TIMEBASED_MIN_TIME_AGO, TimeBasedSubDirDatasetsFinder.DEFAULT_COMPACTION_TIMEBASED_MIN_TIME_AGO); String minTimeAgoStr = getMachedLookbackTime(datasetName, minTimeAgoStrList, TimeBasedSubDirDatasetsFinder.DEFAULT_COMPACTION_TIMEBASED_MIN_TIME_AGO); Period minTimeAgo = formatter.parsePeriod(minTimeAgoStr); latest = compactionStartTime.minus(minTimeAgo); if (earliest.isBefore(folderTime) && latest.isAfter(folderTime)) { log.debug("{} falls in the user defined time range", dataset.datasetRoot()); return new Result(true, ""); } } catch (Exception e) { log.error("{} cannot be verified because of {}", dataset.datasetRoot(), ExceptionUtils.getFullStackTrace(e)); return new Result(false, e.toString()); } return new Result(false, dataset.datasetRoot() + " is not in between " + earliest + " and " + latest); }
Example 16
Source Project: jfixture File: ReadablePeriodRelay.java License: MIT License | 5 votes |
@Override public Object create(Object request, SpecimenContext context) { if (!(request.equals(ReadablePeriod.class) || request.equals(ReadWritablePeriod.class))) return new NoSpecimen(); DateTime dateA = (DateTime) context.resolve(DateTime.class); DateTime dateB = (DateTime) context.resolve(DateTime.class); if (dateA.isBefore(dateB)) return new MutablePeriod(dateA, dateB); else return new MutablePeriod(dateB, dateA); }
Example 17
Source Project: Cubert File: AggregateRewriter.java License: Apache License 2.0 | 4 votes |
private void incrementalizeInputLoad(ObjectNode programNode, ObjectNode inputNode, ObjectNode cubeOperatorNode, String mvName, String mvPath) throws IOException, AggregateRewriteException { // extract input paths from inputNode and adjust start-date to MV refresh date+1. ArrayNode paths = (ArrayNode) inputNode.get("path"); System.out.println("Incrementalize InputNode = " + inputNode.toString()); int newMvRefreshTime = 0; for (int i = 0; i < paths.size(); i++) { JsonNode pathNode = paths.get(i); if (pathNode instanceof ObjectNode) { String startDate = ((ObjectNode) pathNode).get("startDate").getTextValue(); // System.out.println("startDate = " + startDate); DateTime loadStart = DateTimeUtilities.getDateTime((startDate)); String endDate = ((ObjectNode) pathNode).get("endDate").getTextValue(); DateTime loadEnd = DateTimeUtilities.getDateTime(endDate); if (mvRefreshDate != 0 && incLoadDate != null) { if (loadStart.isBefore(incLoadDate) && loadEnd.isAfter(incLoadDate)) { ((ObjectNode) pathNode).put("origStartDate", startDate); ((ObjectNode) pathNode).put("startDate", Integer.toString(DateTimeUtilities.asInt(incLoadDate))); } else throw new AggregateRewriteException(String.format("MV date range mis-matches load range[%s, %s] ", startDate, endDate)); } newMvRefreshTime = Math.max(Integer.parseInt(((ObjectNode) pathNode).get("endDate") .getTextValue()), newMvRefreshTime); } } System.out.println("Setting MV refresh time for " + mvName + " to " + newMvRefreshTime); mvRefreshMap.put(mvName, newMvRefreshTime); }
Example 18
Source Project: dhis2-android-datacapture File: BiWeeklyPeriodFilter.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
private static boolean isDateBeforeSecondEndWeek(DateTime endDate) { return endDate.isBefore(getEndDayOfSecondBiWeek(endDate)) || endDate.isEqual(getEndDayOfSecondBiWeek(endDate)); }
Example 19
Source Project: fenixedu-academic File: WrittenEvaluation.java License: GNU Lesser General Public License v3.0 | 4 votes |
public Boolean getIsAfterCurrentDate() { DateTime currentDate = new DateTime(); return currentDate.isBefore(this.getBeginningDateTime()); }
Example 20
Source Project: nomulus File: GenerateZoneFilesAction.java License: Apache License 2.0 | 4 votes |
@Override public Map<String, Object> handleJsonRequest(Map<String, ?> json) { @SuppressWarnings("unchecked") ImmutableSet<String> tlds = ImmutableSet.copyOf((List<String>) json.get("tlds")); final DateTime exportTime = DateTime.parse(json.get("exportTime").toString()); // We disallow exporting within the past 2 minutes because there might be outstanding writes. // We can only reliably call loadAtPointInTime at times that are UTC midnight and > // datastoreRetention ago in the past. DateTime now = clock.nowUtc(); if (exportTime.isAfter(now.minusMinutes(2))) { throw new BadRequestException("Invalid export time: must be > 2 minutes ago"); } if (exportTime.isBefore(now.minus(datastoreRetention))) { throw new BadRequestException(String.format( "Invalid export time: must be < %d days ago", datastoreRetention.getStandardDays())); } if (!exportTime.equals(exportTime.toDateTime(UTC).withTimeAtStartOfDay())) { throw new BadRequestException("Invalid export time: must be midnight UTC"); } String mapreduceConsoleLink = mrRunner .setJobName("Generate bind file stanzas") .setModuleName("tools") .setDefaultReduceShards(tlds.size()) .runMapreduce( new GenerateBindFileMapper( tlds, exportTime, dnsDefaultATtl, dnsDefaultNsTtl, dnsDefaultDsTtl), new GenerateBindFileReducer(bucket, exportTime, gcsBufferSize), ImmutableList.of(new NullInput<>(), createEntityInput(DomainBase.class))) .getLinkToMapreduceConsole(); ImmutableList<String> filenames = tlds.stream() .map( tld -> String.format( GCS_PATH_FORMAT, bucket, String.format(FILENAME_FORMAT, tld, exportTime))) .collect(toImmutableList()); return ImmutableMap.of( "mapreduceConsoleLink", mapreduceConsoleLink, "filenames", filenames); }