List of usage examples for org.joda.time Interval Interval
public Interval(Object interval, Chronology chronology)
From source file:julian.lylly.model.Task.java
public Duration getTimeSpentInInterval(Interval focus) { if (focus == null) { throw new IllegalArgumentException("focus == nul"); }/*from w w w .ja v a 2s.c om*/ Duration timespent = Duration.ZERO; for (Interval i : intervals) { Duration ov = computeOverlap(i, focus); timespent = timespent.plus(ov); } if (isActive()) { Interval activeInterval = new Interval(starttime, Instant.now()); Duration overlapDuration = computeOverlap(activeInterval, focus); timespent = timespent.plus(overlapDuration); } return timespent; }
From source file:li.klass.fhem.accesibility.MyAccessibilityService.java
License:Open Source License
@Override public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) { DateTime now = new DateTime(); Interval interval = new Interval(lastCommandTime, now); long millis = interval.toDurationMillis(); if (millis < 3000) return;/* w w w . ja v a 2s . c o m*/ lastCommandTime = now; List<CharSequence> texts = accessibilityEvent.getText(); if (texts.isEmpty()) return; String command = texts.get(0).toString(); command = command.toLowerCase(Locale.getDefault()); startService(new Intent(Actions.RECOGNIZE_VOICE_COMMAND).setClass(this, VoiceCommandIntentService.class) .putExtra(BundleExtraKeys.COMMAND, command)); Log.d(MyAccessibilityService.class.getName(), command); }
From source file:mobi.daytoday.DayToDay.DateWrap.java
License:Apache License
/** * Find the difference in days between the given dates and return the result * /*from www. j a v a2s . c o m*/ * @param dateOne * - date in DATE_FORMAT format * @param dateTwo * - date in DATE_FORMAT format * @return number of days between the two given dates * @throws Exception * - if there is any error */ public static long daysBetween(String dateOne, String dateTwo) throws Exception { DateTime firstDate = dtForm.parseDateTime(dateOne); DateTime secondDate = dtForm.parseDateTime(dateTwo); Interval difference; if (firstDate.isAfter(secondDate)) { difference = new Interval(secondDate, firstDate); } else { difference = new Interval(firstDate, secondDate); } return difference.toDuration().getStandardDays(); }
From source file:Model.Perda.java
private LinkedList<Semana> geraSemanas(Mes mes, int ano) { semanas = new LinkedList<>(); DateTime monthStart = new DateTime(getFirstDayOfMonth(mes, ano)); DateTime monthEnd = new DateTime(getLastDayOfMonth(mes, ano)); Interval monthInterval = new Interval(monthStart, monthEnd); /////////////////////// String firstWeekNumber = new SimpleDateFormat("w").format(monthStart); String tempWeek = ""; /////////////////////// // Variaveis temporarias DateTime newWeekStart = new DateTime(); DateTime newWeekEnd = new DateTime(); Interval newInterval = new Interval(newWeekStart, newWeekEnd); DateTime oldWeekStart = new DateTime(); DateTime oldWeekEnd = new DateTime(); Interval oldInterval = new Interval(oldWeekStart, oldWeekEnd); String month = new SimpleDateFormat("MM").format(newWeekStart); /////////////////////// //TODO: gerar as semanas dependendo do numero de semanas com o seu intervalo de cada mes //while....// w ww. j av a 2 s . co m return semanas; }
From source file:module.mission.domain.Mission.java
License:Open Source License
public Interval getInterval() { final DateTime departure = getDaparture(); final DateTime arrival = getArrival(); return new Interval(departure, arrival); }
From source file:module.mission.domain.NationalMission.java
License:Open Source License
@Override public double getFirstDayPersonelDayExpensePercentage(final PersonelExpenseItem personelExpenseItem) { double result = 0.0; final DateTime departure = personelExpenseItem.getStart(); final DateTime arrival = personelExpenseItem.getEnd(); if (!arrival.isAfter(departure)) { return Double.MAX_VALUE; }/*from w w w .j a va 2 s . com*/ final Interval interval = new Interval(departure, arrival); // Check if include lunch period if (overlapsMeal(interval, departure, 13)) { result += 0.25; } // Check if include dinner period if (overlapsMeal(interval, departure, 20)) { result += 0.25; } final DateTime accomodationThreashold = departure.withTime(22, 0, 0, 0); // Check if include accomodations if (personelExpenseItem instanceof FullPersonelExpenseItem && arrival.isAfter(accomodationThreashold)) { result += 0.5; } return result; }
From source file:module.mission.domain.NationalMission.java
License:Open Source License
@Override public double getLastDayPersonelDayExpensePercentage(final PersonelExpenseItem personelExpenseItem) { double result = 0.0; final DateTime departure = personelExpenseItem.getStart(); final DateTime arrival = personelExpenseItem.getEnd(); final Interval interval = new Interval(departure, arrival); // Check if include lunch period if (overlapsMeal(interval, arrival, 13)) { result += 0.25;/*from w w w . j a v a 2 s. com*/ } // Check if include dinner period if (overlapsMeal(interval, arrival, 20)) { result += 0.25; } return result; }
From source file:module.mission.domain.NationalMission.java
License:Open Source License
private boolean overlapsMeal(final Interval interval, final DateTime dateTime, final int hour) { final Interval mealTime = new Interval(dateTime.withTime(hour, 0, 0, 0), Hours.ONE); return interval.overlaps(mealTime); }
From source file:module.mission.domain.NationalMission.java
License:Open Source License
@Override protected boolean discountLunchDay(final DateTime dateTime) { if (super.discountLunchDay(dateTime)) { if (isFirstDay(dateTime)) { final Interval interval = new Interval(getDaparture(), dateTime.withTime(23, 59, 59, 0)); return overlapsMeal(interval, dateTime, 13); } else if (isLastDay(dateTime)) { final Interval interval = new Interval(dateTime.withTime(0, 0, 0, 0), getArrival()); return overlapsMeal(interval, dateTime, 13); }// ww w . j a va 2 s .c om return true; } return false; }
From source file:module.mobility.domain.JobOffer.java
License:Open Source License
private Interval getCandidacyPeriod() { return getPublicationBeginDate() != null && getPublicationEndDate() != null ? new Interval(getPublicationBeginDate(), getPublicationEndDate()) : null;// w ww . j ava 2 s . c o m }