List of usage examples for org.joda.time DateTime plusMinutes
public DateTime plusMinutes(int minutes)
From source file:net.ftlines.wicket.fullcalendar.callback.DateRangeSelectedCallback.java
License:Apache License
@Override protected void respond(final AjaxRequestTarget target) { final Request r = getCalendar().getRequest(); DateTime start = new DateTime(r.getRequestParameters().getParameterValue("startDate").toLong()); DateTime end = new DateTime(r.getRequestParameters().getParameterValue("endDate").toLong()); if (ignoreTimezone) { // Convert to same DateTime in local time zone. final int remoteOffset = -r.getRequestParameters().getParameterValue("timezoneOffset").toInt(); final int localOffset = DateTimeZone.getDefault().getOffset(null) / 60000; final int minutesAdjustment = remoteOffset - localOffset; start = start.plusMinutes(minutesAdjustment); end = end.plusMinutes(minutesAdjustment); }/* w ww . jav a 2 s . c om*/ final boolean allDay = r.getRequestParameters().getParameterValue("allDay").toBoolean(); onSelect(new SelectedRange(start, end, allDay), new CalendarResponse(getCalendar(), target)); }
From source file:net.ftlines.wicket.fullcalendar.callback.GetEventsCallback.java
License:Apache License
@Override protected void respond() { Request r = getCalendar().getRequest(); String sid = r.getRequestParameters().getParameterValue(SOURCE_ID).toString(); DateTime start = new DateTime(r.getRequestParameters().getParameterValue("start").toLong()); DateTime end = new DateTime(r.getRequestParameters().getParameterValue("end").toLong()); if (getCalendar().getConfig().isIgnoreTimezone()) { // Convert to same DateTime in local time zone. int remoteOffset = -r.getRequestParameters().getParameterValue("timezoneOffset").toInt(); int localOffset = DateTimeZone.getDefault().getOffset(null) / 60000; int minutesAdjustment = remoteOffset - localOffset; start = start.plusMinutes(minutesAdjustment); end = end.plusMinutes(minutesAdjustment); }// w w w .java2 s. c o m EventSource source = getCalendar().getEventManager().getEventSource(sid); EventProvider provider = source.getEventProvider(); String response = getCalendar().toJson(provider.getEvents(start, end)); getCalendar().getRequestCycle() .scheduleRequestHandlerAfterCurrent(new TextRequestHandler("application/json", "UTF-8", response)); }
From source file:net.link.util.saml.Saml1Utils.java
License:Open Source License
/** * Checks whether the assertion is well formed and validates against some given data. * * @param assertion the assertion to validate * @param now Check whether the assertion is valid at this instant. * @param expectedAudience expected audience matching the optional audience restriction * * @throws ValidationFailedException validation failed. */// www .jav a 2 s . co m public static void validateAssertion(@NotNull Assertion assertion, @Nullable ReadableDateTime now, @Nullable String expectedAudience) throws ValidationFailedException { Conditions conditions = assertion.getConditions(); DateTime notBefore = conditions.getNotBefore(); DateTime notOnOrAfter = conditions.getNotOnOrAfter(); logger.dbg("now: %s", now); logger.dbg("notBefore: %s", notBefore); logger.dbg("notOnOrAfter : %s", notOnOrAfter); if (now != null) { if (now.isBefore(notBefore)) { // time skew DateTime nowDt = now.toDateTime(); if (nowDt.plusMinutes(5).isBefore(notBefore) || nowDt.minusMinutes(5).isAfter(notOnOrAfter)) throw new ValidationFailedException("SAML2 assertion validation audience=" + expectedAudience + " : invalid SAML message timeframe"); } else if (now.isBefore(notBefore) || now.isAfter(notOnOrAfter)) throw new ValidationFailedException("SAML2 assertion validation audience=" + expectedAudience + " : invalid SAML message timeframe"); } if (assertion.getAuthenticationStatements().isEmpty()) throw new ValidationFailedException( "SAML2 assertion validation audience=" + expectedAudience + " : missing AuthnStatement"); AuthenticationStatement authnStatement = assertion.getAuthenticationStatements().get(0); Subject subject = authnStatement.getSubject(); if (null == subject) throw new ValidationFailedException( "SAML2 assertion validation audience=" + expectedAudience + " : missing Assertion Subject"); SubjectConfirmation subjectConfirmation = subject.getSubjectConfirmation(); if (null == authnStatement.getAuthenticationMethod()) throw new ValidationFailedException( "SAML2 assertion validation audience=" + expectedAudience + " : missing AuthenticationMethod"); if (expectedAudience != null) // Check whether the audience of the response corresponds to the original audience restriction validateAudienceRestriction(conditions, expectedAudience); }
From source file:net.link.util.saml.Saml2Utils.java
License:Open Source License
/** * Checks whether the assertion is well formed and validates against some given data. * * @param assertion the assertion to validate * @param now Check whether the assertion is valid at this instant. * @param expectedAudience expected audience matching the optional audience restriction * * @throws ValidationFailedException validation failed. *///from w w w . j a v a 2 s. c om public static void validateAssertion(@NotNull Assertion assertion, @Nullable ReadableDateTime now, @Nullable String expectedAudience) throws ValidationFailedException { Conditions conditions = assertion.getConditions(); DateTime notBefore = conditions.getNotBefore(); DateTime notOnOrAfter = conditions.getNotOnOrAfter(); logger.dbg("now: %s", now); logger.dbg("notBefore: %s", notBefore); logger.dbg("notOnOrAfter : %s", notOnOrAfter); if (now != null) { if (now.isBefore(notBefore)) { // time skew DateTime nowDt = now.toDateTime(); if (nowDt.plusMinutes(5).isBefore(notBefore) || nowDt.minusMinutes(5).isAfter(notOnOrAfter)) throw new ValidationFailedException("SAML2 assertion validation audience=" + expectedAudience + " : invalid SAML message timeframe"); } else if (now.isBefore(notBefore) || now.isAfter(notOnOrAfter)) throw new ValidationFailedException("SAML2 assertion validation audience=" + expectedAudience + " : invalid SAML message timeframe"); } Subject subject = assertion.getSubject(); if (null == subject) throw new ValidationFailedException( "SAML2 assertion validation audience=" + expectedAudience + " : missing Assertion Subject"); if (subject.getSubjectConfirmations().isEmpty()) throw new ValidationFailedException( "SAML2 assertion validation audience=" + expectedAudience + " : missing SubjectConfirmation"); SubjectConfirmation subjectConfirmation = subject.getSubjectConfirmations().get(0); SubjectConfirmationData subjectConfirmationData = subjectConfirmation.getSubjectConfirmationData(); if (!subjectConfirmationData.getUnknownXMLObjects(KeyInfo.DEFAULT_ELEMENT_NAME).isEmpty()) { // meaning a PublicKey is attached if (subjectConfirmationData.getUnknownXMLObjects(KeyInfo.DEFAULT_ELEMENT_NAME).size() != 1) throw new ValidationFailedException("SAML2 assertion validation audience=" + expectedAudience + " : more then 1 KeyInfo element in SubjectConfirmationData"); } if (assertion.getAuthnStatements().isEmpty()) throw new ValidationFailedException( "SAML2 assertion validation audience=" + expectedAudience + " : missing AuthnStatement"); AuthnStatement authnStatement = assertion.getAuthnStatements().get(0); if (null == authnStatement.getAuthnContext()) throw new ValidationFailedException( "SAML2 assertion validation audience=" + expectedAudience + " : missing AuthnContext"); if (null == authnStatement.getAuthnContext().getAuthnContextClassRef()) throw new ValidationFailedException( "SAML2 assertion validation audience=" + expectedAudience + " : missing AuthnContextClassRef"); if (expectedAudience != null) // Check whether the audience of the response corresponds to the original audience restriction validateAudienceRestriction(conditions, expectedAudience); }
From source file:net.naonedbus.bean.InfoTrafic.java
License:Open Source License
/** * Parser une date selon les diffrents formats possibles : jj/mm/aaaa ou * mm/aaaa et ventuellement une heure./*from w w w . j a va 2s . c o m*/ * * @param date * @param heure * @return le DateTime correspondant */ private static final DateTime parseDate(final String date, final String heure) { DateTime dateTime = null; if (date.length() == 10) { dateTime = sFullDateParser.parseDateTime(date); } else if (date.length() == 7) { dateTime = sSimpleDateParser.parseDateTime(date); } if (dateTime != null && heure != null && heure.length() == 5) { dateTime = dateTime.plusMinutes(sTimeParser.parseDateTime(heure).minuteOfDay().get()); } return dateTime; }
From source file:net.naonedbus.manager.impl.ParkingPublicManager.java
License:Open Source License
/** * Charger les donnes et grer le cache./*from ww w.ja va 2 s. c o m*/ * * @throws IOException * @throws JSONException */ private void init(final Context context) throws IOException, JSONException { final DateTime now = new DateTime(); if (this.mCache.isEmpty() || now.isAfter(this.mDateLimit)) { final ParkingPublicsController controller = new ParkingPublicsController(); this.mCache.clear(); this.mCache = controller.getAll(context.getResources()); this.mDateLimit = now.plusMinutes(CACHE_LIMITE_MINUTES); fillParkings(context.getContentResolver(), this.mCache); } }
From source file:net.sourceforge.fenixedu.domain.serviceRequests.AcademicServiceRequestSituation.java
License:Open Source License
protected void checkParameters(final AcademicServiceRequest academicServiceRequest, final AcademicServiceRequestBean bean) { if (academicServiceRequest == null) { throw new DomainException( "error.serviceRequests.AcademicServiceRequestSituation.academicServiceRequest.cannot.be.null"); }//www . j av a2 s . c o m if (!bean.hasAcademicServiceRequestSituationType()) { throw new DomainException( "error.serviceRequests.AcademicServiceRequestSituation.academicServiceRequestSituationType.cannot.be.null"); } final AcademicServiceRequestSituation activeSituation = academicServiceRequest.getActiveSituation(); if (activeSituation != null) { final DateTime activeSituationDate = activeSituation.getSituationDate(); final DateTime finalSituationDate = bean.getFinalSituationDate(); if (finalSituationDate.toLocalDate().isBefore(activeSituationDate.toLocalDate())) { throw new DomainException( "error.serviceRequests.AcademicServiceRequestSituation.situation.date.is.before"); } if (finalSituationDate.toLocalDate().isEqual(activeSituationDate.toLocalDate()) && finalSituationDate.isBefore(activeSituationDate)) { bean.setFinalSituationDate(activeSituationDate.plusMinutes(1)); } } if (bean.getFinalSituationDate().isAfterNow()) { throw new DomainException( "error.serviceRequests.AcademicServiceRequestSituation.situation.date.is.after"); } if (bean.isToCancelOrReject()) { if (!bean.hasJustification()) { throw new DomainException( "error.serviceRequests.AcademicServiceRequestSituation.justification.cannot.be.null.for.cancelled.and.rejected.situations"); } } }
From source file:net.sourceforge.fenixedu.presentationTier.Action.ICalendarSyncPoint.java
License:Open Source License
private Calendar getClassCalendar(User user, DateTime validity, HttpServletRequest request) { List<EventBean> allEvents = getClasses(user); String url = CoreConfiguration.getConfiguration().applicationUrl() + "/login"; EventBean event = new EventBean("Renovar a chave do calendario.", validity.minusMinutes(30), validity.plusMinutes(30), false, null, url, "A sua chave de sincronizao do calendario vai expirar. Diriga-se ao Fnix para gerar nova chave"); allEvents.add(event);//from ww w . java 2s .com return CalendarFactory.createCalendar(allEvents); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.ICalendarSyncPoint.java
License:Open Source License
private Calendar getExamsCalendar(User user, DateTime validity, HttpServletRequest request) { List<EventBean> allEvents = getExams(user); String url = CoreConfiguration.getConfiguration().applicationUrl() + "/login"; EventBean event = new EventBean("Renovar a chave do calendario.", validity.minusMinutes(30), validity.plusMinutes(30), false, null, url, "A sua chave de sincronizao do calendario vai expirar. Diriga-se ao Fnix para gerar nova chave"); allEvents.add(event);// w w w. j a v a2s. c om return CalendarFactory.createCalendar(allEvents); }
From source file:niche.newres.timedevents2owl.randomizer.TimedEvents2OWLRandomizer.java
public static DateTime plusRandomMinutes(DateTime dateTime, int minRange, int maxRange) { int randomMinutes = TimedEvents2OWLRandomizer.randInt(minRange, maxRange); return dateTime.plusMinutes(randomMinutes); }