List of usage examples for org.joda.time Interval Interval
public Interval(Object interval, Chronology chronology)
From source file:com.cryart.sabbathschool.viewmodel.SSLessonsViewModel.java
License:Open Source License
public void onReadClick() { if (ssQuarterlyInfo != null && ssQuarterlyInfo.lessons.size() > 0) { DateTime today = DateTime.now().withTimeAtStartOfDay(); String ssLessonIndex = ssQuarterlyInfo.lessons.get(0).index; for (SSLesson ssLesson : ssQuarterlyInfo.lessons) { DateTime startDate = DateTimeFormat.forPattern(SSConstants.SS_DATE_FORMAT) .parseDateTime(ssLesson.start_date).withTimeAtStartOfDay(); DateTime endDate = DateTimeFormat.forPattern(SSConstants.SS_DATE_FORMAT) .parseDateTime(ssLesson.end_date).plusDays(1).withTimeAtStartOfDay(); if (new Interval(startDate, endDate).contains(today)) { ssLessonIndex = ssLesson.index; break; }/*from w w w. j ava 2s. c o m*/ } Intent ssReadingIntent = new Intent(context, SSReadingActivity.class); ssReadingIntent.putExtra(SSConstants.SS_LESSON_INDEX_EXTRA, ssLessonIndex); context.startActivity(ssReadingIntent); } }
From source file:com.danhaywood.isis.wicket.fullcalendar.collectioncontents.DateAssociationEventsProvider.java
License:Apache License
public Collection<Event> getEvents(final DateTime start, final DateTime end) { final Interval interval = new Interval(start, end); final Predicate<Event> withinInterval = new Predicate<Event>() { public boolean apply(Event input) { return interval.contains(input.getStart()); }//from w w w . j a v a2s .co m }; final Collection<Event> values = eventById.values(); return Collections2.filter(values, withinInterval); }
From source file:com.enonic.cms.server.service.admin.mvc.controller.ResourceController.java
License:Open Source License
/** * Handle the request.//from ww w . ja v a2s .c o m */ protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { String path = urlPathHelper.getPathWithinApplication(request); Resource resource = this.resourceLoader.getResource(path); if (resource.exists()) { DateTime now = new DateTime(); DateTime expirationDate = now.plusHours(1); HttpCacheControlSettings cacheControlSettings = new HttpCacheControlSettings(); cacheControlSettings.maxAgeSecondsToLive = new Interval(now, expirationDate).toDurationMillis() / 1000; cacheControlSettings.publicAccess = true; HttpServletUtil.setDateHeader(response, now.toDate()); HttpServletUtil.setExpiresHeader(response, expirationDate.toDate()); HttpServletUtil.setCacheControl(response, cacheControlSettings); serveResourceToResponse(request, response, resource); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } return null; }
From source file:com.enonic.cms.server.service.portal.mvc.controller.PortalRenderResponseServer.java
License:Open Source License
private void setHttpCacheHeaders(final User requester, final DateTime requestTime, final DateTime expirationTime, final HttpServletResponse httpResponse, final boolean forceNoCache, final SiteEntity site) { final Interval maxAge = new Interval(requestTime, expirationTime); @SuppressWarnings({ "UnnecessaryLocalVariable" }) boolean notCachableByClient = forceNoCache; if (notCachableByClient) { HttpServletUtil.setCacheControlNoCache(httpResponse); } else {/*from w ww . j a va 2s . co m*/ HttpCacheControlSettings cacheControlSettings = new HttpCacheControlSettings(); // To eliminate proxy caching of pages (decided by TSI) cacheControlSettings.publicAccess = false; boolean setCacheTimeToZero = dynamicResolversEnabled(site); if (setCacheTimeToZero) { cacheControlSettings.maxAgeSecondsToLive = new Long(0); HttpServletUtil.setExpiresHeader(httpResponse, requestTime.toDate()); } else { cacheControlSettings.maxAgeSecondsToLive = maxAge.toDurationMillis() / SECOND_IN_MILLIS; HttpServletUtil.setExpiresHeader(httpResponse, expirationTime.toDate()); } HttpServletUtil.setCacheControl(httpResponse, cacheControlSettings); } }
From source file:com.enonic.cms.web.portal.page.PortalResponseProcessor.java
License:Open Source License
private void setHttpCacheHeaders(final DateTime requestTime, final DateTime expirationTime, final boolean forceNoCache) { final Interval maxAge = new Interval(requestTime, expirationTime); @SuppressWarnings({ "UnnecessaryLocalVariable" }) boolean notCachableByClient = forceNoCache; if (notCachableByClient) { HttpServletUtil.setCacheControlNoCache(httpResponse); } else {/*w ww. ja v a 2s. c o m*/ HttpCacheControlSettings cacheControlSettings = new HttpCacheControlSettings(); // To eliminate proxy caching of pages (decided by TSI) cacheControlSettings.publicAccess = false; boolean setCacheTimeToZero = dynamicResolversEnabled(); if (setCacheTimeToZero) { cacheControlSettings.maxAgeSecondsToLive = new Long(0); HttpServletUtil.setExpiresHeader(httpResponse, requestTime.toDate()); } else { cacheControlSettings.maxAgeSecondsToLive = maxAge.toDurationMillis() / SECOND_IN_MILLIS; HttpServletUtil.setExpiresHeader(httpResponse, expirationTime.toDate()); } HttpServletUtil.setCacheControl(httpResponse, cacheControlSettings); } }
From source file:com.eucalyptus.simpleworkflow.common.client.WorkflowTimer.java
License:Open Source License
static List<WorkflowStarter> markAndGetRepeatingStarters() { try {/*from ww w . ja va2s. co m*/ final List<WorkflowStarter> starters = Lists.newArrayList(); listRepeatingWorkflows().stream().forEach((impl) -> { try { final Repeating ats = Ats.inClassHierarchy(impl).get(Repeating.class); if (Topology.isEnabled(ats.dependsOn())) { final Long lastRun = lastExecution.get(impl); if (lastRun != null) { final DateTime now = new DateTime(System.currentTimeMillis()); final DateTime sleepBegin = now.minusSeconds(ats.sleepSeconds()); final Interval interval = new Interval(sleepBegin, now); if (!interval.contains(new DateTime(lastRun))) { if (lastExecution.replace(impl, lastRun, System.currentTimeMillis())) { starters.add(ats.value().newInstance()); } } } } } catch (InstantiationException ex) { ; } catch (IllegalAccessException ex) { ; } }); return starters; } catch (final Exception ex) { return Lists.newArrayList(); } }
From source file:com.flipkart.foxtrot.core.common.PeriodSelector.java
License:Apache License
public Interval analyze(long currentTime) throws Exception { for (Filter filter : filters) { if (filter.isFilterTemporal()) { filter.accept(this); }//from w w w . j a v a 2 s . c o m } timeWindow.setStartTime(timeWindow.getStartTime() == Long.MAX_VALUE ? 0 : timeWindow.getStartTime()); timeWindow.setEndTime(timeWindow.getEndTime() == Long.MIN_VALUE ? currentTime : timeWindow.getEndTime()); return new Interval(timeWindow.getStartTime(), timeWindow.getEndTime()); }
From source file:com.floreantpos.swing.TimerWatch.java
License:Open Source License
@Override public void actionPerformed(ActionEvent e) { Interval interval = new Interval(date.getTime(), new Instant().getMillis()); Duration duration = interval.toDuration(); int timeOutValueYellow = 300; int timeOutValueRed = 600; if (AppConfig.getString("YellowTimeOut") != null) { timeOutValueYellow = Integer.parseInt(AppConfig.getString("YellowTimeOut")); //$NON-NLS-1$ }//from www.j av a2 s . co m if (AppConfig.getString("RedTimeOut") != null) { timeOutValueRed = Integer.parseInt(AppConfig.getString("RedTimeOut")); //$NON-NLS-1$ } if (timeOutValueYellow < duration.getStandardSeconds() && timeOutValueRed > duration.getStandardSeconds()) { backColor = Color.yellow; textColor = Color.black; } else if (timeOutValueRed < duration.getStandardSeconds()) { backColor = Color.red; textColor = Color.white; } else { backColor = Color.white; textColor = Color.black; } timerLabel.setText(duration.getStandardHours() + ":" + (duration.getStandardMinutes() % 60) + ":" //$NON-NLS-1$//$NON-NLS-2$ + (duration.getStandardSeconds() % 60)); }
From source file:com.fusesource.examples.horo.model.StarSign.java
License:Apache License
public boolean appliesTo(ReadableDateTime dateTime) { Validate.notNull(dateTime);//from www . j a v a 2 s . co m int year = dateTime.getYear(); Interval signInterval = new Interval(start.toLocalDate(year).toDateMidnight(), end.toLocalDate(year).toDateMidnight().plusDays(1)); return signInterval.contains(dateTime); }
From source file:com.github.dbourdette.otto.data.SimpleDataTable.java
License:Apache License
public static SimpleDataTable forInterval(DateTime start, DateTime end) { return forInterval(new Interval(start, end)); }