List of usage examples for org.joda.time Interval Interval
public Interval(Object interval, Chronology chronology)
From source file:de.rwth.idsg.xsharing.router.persistence.domain.util.ConverterUtil.java
License:Open Source License
@Nullable public static Interval getInterval(@Nullable String from, @Nullable String to) { if (isNullOrEmpty(from) || isNullOrEmpty(to)) { return null; }//from w w w. j ava2s .co m DateTime fromLdt = FORMATTER.parseDateTime(from); DateTime toLdt = FORMATTER.parseDateTime(to); return new Interval(fromLdt, toLdt); }
From source file:de.rwth.idsg.xsharing.router.utils.DateTimeUtils.java
License:Open Source License
/** * For some checks, we need a mechanism to express "if the time is _around_ current time". * With this, we return a time window with "current time offset". *//*from w w w.ja va 2s. c o m*/ public static Interval getNowTimeWindow() { long now = org.joda.time.DateTimeUtils.currentTimeMillis(); return new Interval(now - OFFSET_FOR_CHECK, now + OFFSET_FOR_CHECK_END); }
From source file:de.topobyte.joda.utils.MonthSpan.java
License:Open Source License
public Interval toInterval() { Interval m1 = limitLower.toInterval(); Interval m2 = limitUpper.toInterval(); return new Interval(m1.getStart(), m2.getStart()); }
From source file:Dialogos.RetiroDialogo.java
/** * Creates new form RetiroDialogo/*from w ww . java 2 s . c o m*/ */ public RetiroDialogo(java.awt.Frame parent, boolean modal, Cupo cupo) { super(parent, modal); initComponents(); this.cupo = cupo; this.setLocationRelativeTo(parent); placa.setText(cupo.getPlaca().getPlaca()); Interval intervalo = new Interval(new Instant(cupo.getCupoPK().getIngreso().getTime()), new Instant(cupo.getSalida().getTime())); Period period = intervalo.toPeriod(); PeriodFormatter minutesAndSeconds = new PeriodFormatterBuilder().printZeroAlways().appendHours() .appendSeparator(":").appendMinutes().toFormatter(); String result = minutesAndSeconds.print(period); tiempo.setText(result); cobroFinal.setText(String.valueOf(cupo.getCobroSugerido())); if (cupo.getLocker() != null) { locker.setText(String.format("%s : %d", cupo.getLocker().getIdentificador(), cupo.getLocker().getAlojamiento())); } else { locker.setText("Ninguno"); } observaciones.setText(cupo.getPlaca().getUsuario().getObservacion()); this.setVisible(true); }
From source file:dk.dma.commons.util.DateTimeUtil.java
License:Apache License
public static Interval toInterval(Date startDate, Date endDate) { return new Interval(startDate.getTime(), endDate.getTime()); }
From source file:dk.nsi.sdm4.ydelse.parser.SSRLineParser.java
License:Open Source License
public Interval parseIntervalFromTwoIdenticalDaysAsSpecifiedBySsr(String[] fields, int treatmentStartTimeField, int treatmentEndTimeField) throws ParserException { if (fieldIsMissing(fields, treatmentStartTimeField)) { throw new ParserException("Treatment start time must be present"); }// w ww . ja v a 2 s . c o m if (fieldIsMissing(fields, treatmentEndTimeField)) { throw new ParserException("Treatment end time must be present"); } DateTime admittedStart; try { admittedStart = parseDateAsSpecifiedBySsr(fields[treatmentStartTimeField]); } catch (ParseException e) { throw new ParserException("Treatment start time is malformed: " + fields[treatmentStartTimeField]); } DateTime admittedEnd; try { admittedEnd = parseDateAsSpecifiedBySsr(fields[treatmentEndTimeField]); } catch (ParseException e) { throw new ParserException("Treatment end time is malformed: " + fields[treatmentEndTimeField]); } if (!admittedStart.equals(admittedEnd)) { throw new ParserException("Treatment end time must be the same day as the treatment start time"); } admittedEnd = admittedEnd.plusDays(1); return new Interval(admittedStart, admittedEnd); }
From source file:dk.nsi.sdm4.ydelse.relation.model.SSR.java
License:Open Source License
public SSR withTreatmentIntervalIgnoringMillis(Interval admittedInterval) { if (admittedInterval == null) { throw new IllegalArgumentException("Admitted interval must be non-null."); }/*from w w w .ja v a2 s. c o m*/ DateTime start = admittedInterval.getStart().minusMillis(admittedInterval.getStart().getMillisOfSecond()); DateTime end = admittedInterval.getEnd().minusMillis(admittedInterval.getEnd().getMillisOfSecond()); admittedInterval = new Interval(start, end); SSR ssr = new SSR(this); ssr.admittedInterval = admittedInterval; return ssr; }
From source file:dk.nsi.sdm4.ydelse.simulation.RandomSSR.java
License:Open Source License
private void setRandomTreatmentTime() { DateTime earliestTreatmentStart = new DateTime(2010, 12, 24, 0, 0, 0, 0); DateTime latestTreatmentStart = new DateTime(2011, 1, 31, 0, 0, 0, 0); DateTime treatet = testDataUtil.randomTime(earliestTreatmentStart, latestTreatmentStart); treatet = treatet.withTime(0, 0, 0, 0); treatmentInterval = new Interval(treatet, treatet.plusDays(1)); }
From source file:dk.teachus.backend.domain.impl.PeriodImpl.java
License:Apache License
public boolean conflicts(DateTime bookedTime, DateTime time) { boolean conflicts = false; // On the same date if (bookedTime.toDateMidnight().equals(time.toDateMidnight())) { bookedTime = DateUtils.resetDateTime(bookedTime, time); time = DateUtils.resetDateTime(time, time); DateTime st = bookedTime.minusMinutes(lessonDuration); DateTime et = bookedTime.plusMinutes(lessonDuration); Interval bookedInterval = new Interval(st, et); if (bookedInterval.contains(time) && st.equals(time) == false) { conflicts = true;/*from w ww . j av a2 s . c om*/ } } return conflicts; }
From source file:dk.teachus.backend.domain.impl.PeriodImpl.java
License:Apache License
public boolean dateIntervalContains(DateMidnight date) { DateMidnight start = beginDate;/*from w w w . j a va 2s . c o m*/ DateMidnight end = endDate; boolean contains = false; if (start != null && end != null) { Interval interval = new Interval(start, end); contains = interval.contains(date) || date.equals(end); } else if (start != null) { contains = date.isAfter(start) || date.equals(start); } else if (end != null) { contains = date.isBefore(end) || date.equals(end); } else { contains = true; } return contains; }