List of usage examples for org.joda.time DateTime plus
public DateTime plus(ReadablePeriod period)
From source file:org.jasig.cas.web.view.Saml10SuccessResponseView.java
License:Apache License
private Conditions newConditions(final DateTime issuedAt, final String serviceId) { final Conditions conditions = newSamlObject(Conditions.class); conditions.setNotBefore(issuedAt);/*w w w .j a v a 2 s. c o m*/ conditions.setNotOnOrAfter(issuedAt.plus(this.issueLength)); final AudienceRestrictionCondition audienceRestriction = newSamlObject(AudienceRestrictionCondition.class); final Audience audience = newSamlObject(Audience.class); audience.setUri(serviceId); audienceRestriction.getAudiences().add(audience); conditions.getAudienceRestrictionConditions().add(audienceRestriction); return conditions; }
From source file:org.jasig.portal.events.aggr.PortalEventAggregationManagerImpl.java
License:Apache License
void doPopulateDateDimensions() { final DateTime now = getNow(); final AggregationIntervalInfo startIntervalInfo; final DateTime oldestPortalEventTimestamp = this.portalEventDao.getOldestPortalEventTimestamp(); if (oldestPortalEventTimestamp == null || now.isBefore(oldestPortalEventTimestamp)) { startIntervalInfo = this.intervalHelper.getIntervalInfo(AggregationInterval.YEAR, now.minus(this.dimensionBuffer)); } else {/*from w w w.j av a 2s. c om*/ startIntervalInfo = this.intervalHelper.getIntervalInfo(AggregationInterval.YEAR, oldestPortalEventTimestamp.minus(this.dimensionBuffer)); } final AggregationIntervalInfo endIntervalInfo; final DateTime newestPortalEventTimestamp = this.portalEventDao.getNewestPortalEventTimestamp(); if (newestPortalEventTimestamp == null || now.isAfter(newestPortalEventTimestamp)) { endIntervalInfo = this.intervalHelper.getIntervalInfo(AggregationInterval.YEAR, now.plus(this.dimensionBuffer)); } else { endIntervalInfo = this.intervalHelper.getIntervalInfo(AggregationInterval.YEAR, newestPortalEventTimestamp.plus(this.dimensionBuffer)); } final DateMidnight start = startIntervalInfo.getStart().toDateMidnight(); final DateMidnight end = endIntervalInfo.getEnd().toDateMidnight(); doPopulateDateDimensions(start, end); }
From source file:org.jevis.commons.dataprocessing.Options.java
License:Open Source License
/** * Return sthe first period matching the period, offset and target date * * @param date target date to find the matching period * @param period period//w w w .j av a 2 s . c om * @param offset start offset * @return */ public static DateTime findFirstDuration(DateTime date, Period period, DateTime offset) { // System.out.println("findFirstDuration: " + date + " p: " + period); DateTime startD = new DateTime(); DateTime fistPeriod = offset; // System.out.println("week: " + date.getWeekOfWeekyear()); // while (fistPeriod.isBefore(date) || fistPeriod.isEqual(date)) { fistPeriod = fistPeriod.plus(period); } fistPeriod = fistPeriod.minus(period); System.out.println("finding date in: " + ((new DateTime()).getMillis() - startD.getMillis()) + "ms"); System.out.println("first offset date: offset:" + offset + " for period: " + period + " input date: " + date + " fistPeriod: " + fistPeriod); return fistPeriod; }
From source file:org.jevis.commons.dataprocessing.Options.java
License:Open Source License
/** * * @param period//from w ww. j a v a 2 s . c o m * @param offset * @param firstSample * @param lastSample * @return */ public static List<Interval> buildIntervals(Period period, DateTime offset, DateTime firstSample, DateTime lastSample) { DateTime benchMarkStart = new DateTime(); List<Interval> result = new ArrayList<>(); DateTime startDate = findFirstDuration(firstSample, period, offset); result.add(new Interval(startDate, period)); boolean run = true; // DateTime time = startDate; while (run) { startDate = startDate.plus(period); if (startDate.isAfter(lastSample)) { // System.out.println("wtf: " + startDate.getMillis() + " " + lastSample.getMillis()); // System.out.println("faild Interval: " + startDate + " is after " + lastSample); run = false; } else { result.add(new Interval(startDate, period)); } } DateTime benchMarkEnd = new DateTime(); System.out.println("Time to create Intervals[" + result.size() + "]: in " + (benchMarkEnd.getMillis() - benchMarkStart.getMillis()) + "ms"); return result; }
From source file:org.jevis.commons.dataprocessing.ProcessOptions.java
License:Open Source License
/** * Return sthe first period matching the period, offset and target date * * @param date target date to find the matching period * @param period period//from w w w. j av a 2 s .c o m * @param offset start offset * @return */ public static DateTime findFirstDuration(DateTime date, Period period, DateTime offset) { // System.out.println("findFirstDuration: " + date + " p: " + period); DateTime startD = new DateTime(); DateTime fistPeriod = offset; // System.out.println("week: " + date.getWeekOfWeekyear()); // while (fistPeriod.isBefore(date) || fistPeriod.isEqual(date)) { fistPeriod = fistPeriod.plus(period); } fistPeriod = fistPeriod.minus(period); System.out.println("finding date in: " + ((new DateTime()).getMillis() - startD.getMillis()) + "ms"); System.out.println("first offset date: offset:" + offset + " for period: " + period + " input date: " + date + " fistPeriod: " + fistPeriod); return fistPeriod; }
From source file:org.jevis.jeconfig.sample.SampleGraphExtension.java
License:Open Source License
private XYChart.Series buildSeries(List<JEVisSample> samples, int intervall) throws JEVisException { XYChart.Series series1 = new XYChart.Series(); DateTime firstDate = samples.get(0).getTimestamp(); DateTime lastDate = samples.get(samples.size() - 1).getTimestamp(); DateTime now = new DateTime(firstDate); int lastPos = 0; while (now.isBefore(lastDate)) { DateTime newStep = now.plus(intervall); for (int i = lastPos; i < samples.size(); i++) { JEVisSample sample = samples.get(i); DateTime ts = sample.getTimestamp(); if (ts.isBefore(newStep)) { // System.out.println("add TS1: " + (ts.getMillis() / 1000 / 60) + " " + sample.getValueAsDouble()); XYChart.Data data = new XYChart.Data((Number) (ts.getMillis() / 1000 / 60), sample.getValueAsDouble()); Tooltip.install(data.getNode(), new Tooltip("Timestamp: " + sample.getTimestamp().toString() + "\n" + "value : " + sample.getValueAsString())); series1.getData().add(data); // series1.getData().add(new XYChart.Data((Number) (ts.getMillis() / 1000 / 60), sample.getValueAsDouble())); lastPos = i;// w ww . j a v a 2 s . c o m } else if (ts.equals(newStep)) { XYChart.Data data = new XYChart.Data((Number) (ts.getMillis() / 1000 / 60), sample.getValueAsDouble()); Tooltip.install(data.getNode(), new Tooltip("Timestamp: " + sample.getTimestamp().toString() + "\n" + "value : " + sample.getValueAsString())); // System.out.println("add TS2: " + (ts.getMillis() / 1000 / 60) + " " + sample.getValueAsDouble()); series1.getData().add(data); // series1.getData().add(new XYChart.Data((Number) (ts.getMillis() / 1000 / 60), sample.getValueAsDouble())); lastPos = i; break; } else { // System.out.println("add TS3: " + (ts.getMillis() / 1000 / 60) + " " + sample.getValueAsDouble()); series1.getData().add(new XYChart.Data((Number) (newStep.getMillis() / 1000 / 60), 0));//? get Last Sample break; } } now = newStep; } return series1; }
From source file:org.kalypso.ogc.sensor.filter.filters.interval.IntervalIterator.java
License:Open Source License
public IntervalIterator(final DateTime start, final DateTime end, final Period step) { m_end = end;//from ww w . j ava 2 s . c o m m_step = step; final DateTime nextEnd = start.plus(step); // TODO check: is that what we want? If start/end is smaller than the step; the iteration is empty if (nextEnd.isAfter(end)) m_next = null; else m_next = new Interval(start, nextEnd); }
From source file:org.kalypso.ogc.sensor.filter.filters.interval.IntervalIterator.java
License:Open Source License
private Interval updateNext() { if (m_next == null) throw new NoSuchElementException(); final Interval oldNext = m_next; final DateTime end = m_next.getEnd(); final DateTime nextEnd = end.plus(m_step); if (nextEnd.isAfter(m_end)) m_next = null;/*w w w . j a v a 2 s.com*/ else m_next = new Interval(end, nextEnd); return oldNext; }
From source file:org.kalypso.ui.rrm.internal.calccase.CatchmentModelHelper.java
License:Open Source License
/** * This function calculates the range for the timeseries to be generated. The range equals the range defined in the * simulation adjusted as follows:// w w w.j ava2 s . c om * <ul> * <li>1 timestep earlier</li> * <li>3 timesteps later</li> * </ul> * * @param control * The na control. * @param timestep * The timestep. * @param timestamp * The timestamp in UTC. * @return The date range. */ public static DateRange getRange(final NAControl control, final Period timestep, final LocalTime timestamp) { final Date simulationStart = control.getSimulationStart(); final Date simulationEnd = control.getSimulationEnd(); final DateTime start = new DateTime(simulationStart); final DateTime end = new DateTime(simulationEnd); final DateTime adjustedStart = start.minus(timestep); final DateTime adjustedEnd = end.plus(timestep).plus(timestep).plus(timestep); if (timestep.getDays() == 0 || timestamp == null) return new DateRange(adjustedStart.toDate(), adjustedEnd.toDate()); /* Convert to a date with the kalypso timezone. */ /* The date fields are ignored. */ final DateTime timestampUTC = timestamp .toDateTimeToday(DateTimeZone.forTimeZone(TimeZone.getTimeZone("UTC"))); //$NON-NLS-1$ final DateTime timestampDate = new DateTime(timestampUTC.toDate(), DateTimeZone.forTimeZone(KalypsoCorePlugin.getDefault().getTimeZone())); /* Further adjust range by predefined time. */ final DateTime startWithTime = adjustedStart.withTime(timestampDate.getHourOfDay(), timestampDate.getMinuteOfHour(), timestampDate.getSecondOfMinute(), timestampDate.getMillisOfSecond()); final DateTime endWithTime = adjustedEnd.withTime(timestampDate.getHourOfDay(), timestampDate.getMinuteOfHour(), timestampDate.getSecondOfMinute(), timestampDate.getMillisOfSecond()); /* New start must always be before unadjusted start, fix, if this is not the case. */ DateTime startWithTimeFixed; if (startWithTime.isAfter(adjustedStart)) startWithTimeFixed = startWithTime.minus(timestep); else startWithTimeFixed = startWithTime; /* New end must always be after unadjusted end, fix, if this is not the case. */ DateTime endWithTimeFixed; if (endWithTime.isBefore(adjustedEnd)) endWithTimeFixed = endWithTime.plus(timestep); else endWithTimeFixed = endWithTime; return new DateRange(startWithTimeFixed.toDate(), endWithTimeFixed.toDate()); }
From source file:org.killbill.billing.plugin.notification.setup.EmailNotificationListener.java
License:Apache License
private void sendEmailForUpComingInvoice(final Account account, final ExtBusEvent killbillEvent, final TenantContext context) throws IOException, InvoiceApiException, EmailException, TenantApiException { Preconditions.checkArgument(killbillEvent.getEventType() == ExtBusEventType.INVOICE_NOTIFICATION, String.format("Unexpected event %s", killbillEvent.getEventType())); final String dryRunTimePropValue = configProperties.getString(INVOICE_DRY_RUN_TIME_PROPERTY); Preconditions.checkArgument(dryRunTimePropValue != null, String.format("Cannot find property %s", INVOICE_DRY_RUN_TIME_PROPERTY)); final TimeSpan span = new TimeSpan(dryRunTimePropValue); final DateTime now = clock.getClock().getUTCNow(); final DateTime targetDateTime = now.plus(span.getMillis()); final PluginCallContext callContext = new PluginCallContext(EmailNotificationActivator.PLUGIN_NAME, now, context.getTenantId());//from w w w . j a v a 2s . c o m final Invoice invoice = osgiKillbillAPI.getInvoiceUserApi().triggerInvoiceGeneration(account.getId(), new LocalDate(targetDateTime, account.getTimeZone()), NULL_DRY_RUN_ARGUMENTS, callContext); if (invoice != null) { final EmailContent emailContent = templateRenderer.generateEmailForUpComingInvoice(account, invoice, context); sendEmail(account, emailContent, context); } }