List of usage examples for org.joda.time Days daysBetween
public static Days daysBetween(ReadablePartial start, ReadablePartial end)
Days
representing the number of whole days between the two specified partial datetimes. From source file:org.zkoss.ganttz.TaskComponent.java
License:Open Source License
public void updateCompletionReportedHours() { if (task.isShowingReportedHours()) { int startPixels = this.task.getBeginDate().toPixels(getMapper()); String widthHoursAdvancePercentage = pixelsFromStartUntil(startPixels, this.task.getHoursAdvanceBarEndDate()) + "px"; response(null, new AuInvoke(this, "resizeCompletionAdvance", widthHoursAdvancePercentage)); Date firstTimesheetDate = task.getFirstTimesheetDate(); Date lastTimesheetDate = task.getLastTimesheetDate(); if (firstTimesheetDate != null && lastTimesheetDate != null) { Duration firstDuration = Days .daysBetween(task.getBeginDateAsLocalDate(), LocalDate.fromDateFields(firstTimesheetDate)) .toStandardDuration(); int pixelsFirst = getMapper().toPixels(firstDuration); String positionFirst = pixelsFirst + "px"; Duration lastDuration = Days.daysBetween(task.getBeginDateAsLocalDate(), LocalDate.fromDateFields(lastTimesheetDate).plusDays(1)).toStandardDuration(); int pixelsLast = getMapper().toPixels(lastDuration); String positionLast = pixelsLast + "px"; response(null, new AuInvoke(this, "showTimsheetDateMarks", positionFirst, positionLast)); } else {/* ww w .j a va 2s .c o m*/ response(null, new AuInvoke(this, "hideTimsheetDateMarks")); } } else { response(null, new AuInvoke(this, "resizeCompletionAdvance", "0px")); response(null, new AuInvoke(this, "hideTimsheetDateMarks")); } }
From source file:org.zkoss.ganttz.timetracker.TimeTrackerComponent.java
License:Open Source License
public int getDiffDays(LocalDate previousStart) { // Get the current data LocalDate start = getTimeTracker().getRealInterval().getStart(); return Days.daysBetween(start, previousStart).getDays(); }
From source file:org.zkoss.ganttz.timetracker.zoom.DetailItem.java
License:Open Source License
public void markCurrentDay() { if (this.startDate.isBeforeNow() && this.endDate.isAfterNow()) { int offsetInPx = Math .round(((((float) Days.daysBetween(this.startDate, new DateTime()).getDays()) + (float) 0.5) / ((float) Days.daysBetween(this.startDate, this.endDate).getDays())) * this.size); // 1px per column side, 1px for right border and 1px own bg-width this.markCurrentDay(Math.min(this.size - 4, offsetInPx)); }//from w w w . j av a 2s. co m }
From source file:org.zkoss.ganttz.timetracker.zoom.DetailItem.java
License:Open Source License
public void markProjectStart(DateTime projectStart) { if (!this.startDate.isAfter(projectStart) && projectStart.isBefore(endDate)) { int offsetInPx = Math.round((((float) Days.daysBetween(this.startDate, projectStart).getDays()) / ((float) Days.daysBetween(this.startDate, this.endDate).getDays())) * this.size); this.markprojectStart(offsetInPx); }//from w ww . j a va 2 s . c o m }
From source file:org.zkoss.ganttz.timetracker.zoom.DetailItem.java
License:Open Source License
public void markDeadlineDay(DateTime maxdeadline) { DateTime deadline = maxdeadline.plusDays(1); if (!this.startDate.isAfter(deadline) && deadline.isBefore(endDate)) { int offsetInPx = Math.round((((float) Days.daysBetween(this.startDate, deadline).getDays()) / ((float) Days.daysBetween(this.startDate, this.endDate).getDays())) * this.size); // 1px per column side, 1px for right border and 1px own bg-width this.markDeadlineDay(Math.min(this.size - 4, offsetInPx)); }//from w w w. j av a 2s . c om }
From source file:org.zkoss.ganttz.timetracker.zoom.ZoomLevel.java
License:Open Source License
public static ZoomLevel getDefaultZoomByDates(LocalDate initDate, LocalDate endDate) { if (initDate != null && endDate != null) { int days = Days.daysBetween(initDate, endDate).getDays(); for (ZoomLevel each : ZoomLevel.values()) { if (each.isSuitableFor(days)) { return each; }//from www . j ava 2 s .c o m } } return ZoomLevel.DETAIL_ONE; }
From source file:org.zkoss.ganttz.util.Interval.java
License:Open Source License
public Interval(LocalDate startInclusive, LocalDate endExclusive) { Validate.notNull(startInclusive);/*from ww w . j a v a 2 s .co m*/ Validate.notNull(endExclusive); Validate.isTrue(endExclusive.isAfter(startInclusive)); this.startInclusive = startInclusive; this.endExclusive = endExclusive; this.lengthBetween = new Duration(this.startInclusive.toDateTimeAtStartOfDay(), this.endExclusive.toDateTimeAtStartOfDay()); this.daysBetween = Days.daysBetween(this.startInclusive, this.endExclusive); }
From source file:org.zkoss.ganttz.util.Interval.java
License:Open Source License
public Fraction getProportion(DateTime date) { Days fromStartToDate = Days.daysBetween(startInclusive, date.toLocalDate()); Fraction result = Fraction.getFraction(fromStartToDate.getDays(), this.daysBetween.getDays()); try {/*from www. jav a 2s . c o m*/ return result.add(inTheDayIncrement(date)); } catch (ArithmeticException e) { return result; } }
From source file:Presentacion.frmreserva.java
private void txtcosto_alojamientoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtcosto_alojamientoFocusGained if (dcfecha_ingresa.getDate() == null || dcfecha_ingresa.getDate() == null || this.valorAlguel == null || !this.txtcosto_alojamiento.getText().isEmpty()) { return;/* www . j a v a2s . c om*/ } DateTime jdEntrada = new DateTime(dcfecha_ingresa.getDate().getTime()); DateTime jdSaida = new DateTime(dcfecha_salida.getDate().getTime()); Integer numDiasEstadia = Days.daysBetween(jdEntrada, jdSaida).getDays(); txtcosto_alojamiento.setText(Integer.toString(Integer.valueOf(this.valorAlguel) * numDiasEstadia)); }
From source file:projectresurrection.Eve.java
public static void main(String args[]) { init();/*from w w w .j av a 2 s.c o m*/ listener = new Listener(); voice = new VoiceSynthesis(); clock = new Clock(Clock.BRAIN, Clock.UPDATE, (String) preferences.get("time zone")); gui = new GUI(GUI.DEFAULT); gui.start(GUI.DEFAULT); while (true) { if (!commands.isEmpty()) { String command = commands.poll(); prevCommands.add(command); switch (command) { case "what is the current weather": Clock.addCommand("kill"); List currentWeather = Weather.getCurrent(); sb = "The Current Tempurature is " + currentWeather.get(1) + " degrees fahrenheit and " + ((currentWeather.get(2).equals("Thunderstorm In Vicinity")) ? "there is a " : "is ") + currentWeather.get(2); if (!currentWeather.get(3).equals("0")) { sb += ", with wind traveling at " + currentWeather.get(3) + " miles per hour "; switch ((String) currentWeather.get(5)) { case "N": sb += "North"; break; case "NNE": sb += "North North East"; break; case "NE": sb += "North East"; break; case "ENE": sb += "East North East"; break; case "E": sb += "East"; break; case "ESE": sb += "East South East"; break; case "SE": sb += "South East"; break; case "SSE": sb += "South South East"; break; case "S": sb += "South"; break; case "SSW": sb += "South South West"; break; case "SW": sb += "South West"; break; case "WSW": sb += "West South West"; break; case "W": sb += "West"; break; case "WNW": sb += "West North West"; break; case "NW": sb += "North West"; break; case "NNW": sb += "North North West"; break; } } voice.say(sb); break; case "what time is it": date = new DateTime(clock.getCurrent()); voice.say( "It is " + date.getHourOfDay() % 12 + ":" + ((date.getMinuteOfHour() < 10) ? "oh " : "") + date.getMinuteOfHour() + ((date.getHourOfDay() > 12) ? " P.M." : " A.M.")); break; case "what is the date": date = new DateTime(clock.getCurrent()); sb = "It is the "; switch (date.getDayOfMonth()) { case 1: sb += "first"; break; case 2: sb += "second"; break; case 3: sb += "third"; break; case 4: sb += "fourth"; break; case 5: sb += "fifth"; break; case 6: sb += "sixth"; break; case 7: sb += "seventh"; break; case 8: sb += "eighth"; break; case 9: sb += "ninth"; break; case 10: sb += "tenth"; break; case 11: sb += "eleventh"; break; case 12: sb += "twelth"; break; case 13: sb += "thirteenth"; break; case 14: sb += "fourteenth"; break; case 15: sb += "fifteenth"; break; case 16: sb += "sixteenth"; break; case 17: sb += "seventeenth"; break; case 18: sb += "eighteenth"; break; case 19: sb += "nineteenth"; break; case 20: sb += "twentieth"; break; case 21: sb += "twenty-first"; break; case 22: sb += "twenty-second"; break; case 23: sb += "twenty-third"; break; case 24: sb += "twenty-fourth"; break; case 25: sb += "twenty-fifth"; break; case 26: sb += "twenty-sixth"; break; case 27: sb += "twenty-seventh"; break; case 28: sb += "twenty-eighth"; break; case 29: sb += "twenty-ninth"; break; case 30: sb += "thirtieth"; break; case 31: sb += "thirty-first"; break; } sb += " of "; switch (date.getMonthOfYear()) { case 1: sb += "January"; break; case 2: sb += "Feburary"; break; case 3: sb += "March"; break; case 4: sb += "April"; break; case 5: sb += "May"; break; case 6: sb += "June"; break; case 7: sb += "July"; break; case 8: sb += "August"; break; case 9: sb += "September"; break; case 10: sb += "October"; break; case 11: sb += "November"; break; case 12: sb += "December"; break; } sb += ", " + date.getYear(); voice.say(sb); break; case "what day is it": date = new DateTime(clock.getCurrent()); sb = "Today is "; switch (date.getDayOfWeek()) { case (1): sb += "Mondaay"; break; case (2): sb += "Tuesdaay"; break; case (3): sb += "Wednesdaay"; break; case (4): sb += "Thursdaay"; break; case (5): sb += "Fridaay"; break; case (6): sb += "Saturdaay"; break; case (7): sb += "Sundaay"; break; } voice.say(sb); break; case "create a reminder": break; case "how old are you": sb = "I am "; DateTime current = clock.getCurrent(); Period diff = new Period(birth, current); int days = Days.daysBetween(birth, current).getDays(); int hours = Hours.hoursBetween(birth, current).getHours() % 24; int minutes = Minutes.minutesBetween(birth, current).getMinutes() % 60; int seconds = Seconds.secondsBetween(birth, current).getSeconds() % 60; switch (days) { case 0: sb += ""; break; case 1: if (hours == 0 && minutes == 0 && seconds == 0) { sb += days + " day old."; } else { sb += days + " day, "; } break; default: if (hours == 0 && minutes == 0 && seconds == 0) { sb += days + " days old."; } else { sb += days + " days, "; } break; } switch (hours) { case 0: sb += ""; break; case 1: if (minutes == 0 && seconds == 0) { sb += "and " + hours + " hour old."; } else { sb += hours + " hour, "; break; } break; default: if (minutes == 0 && seconds == 0) { sb += "and " + hours + " hours old."; } else { sb += hours + " hours, "; } break; } switch (minutes) { case 0: sb += ""; break; case 1: if (seconds == 0) { sb += "and " + minutes + " minute old."; } else { sb += minutes + " minute, "; } break; default: if (seconds == 0) { sb += "and " + minutes + " minutes old."; } else { sb += minutes + " minutes, "; } break; } switch (seconds) { case 0: sb += ""; break; case 1: sb += "and " + seconds + " second old."; default: sb += "and " + seconds + " seconds old."; break; } voice.say(sb); break; case "change preferences": updatePref(); break; case "": voice.say("Lee dul lee dul lee dul leeee"); break; case "repeat": voice.repeatSlow(); break; default: voice.say(command); break; } } else { try { Thread.sleep(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } }