List of usage examples for org.joda.time LocalDateTime compareTo
public int compareTo(ReadablePartial partial)
From source file:com.alliander.osgp.domain.core.valueobjects.smartmetering.CosemDateTime.java
License:Open Source License
@Override public int compareTo(final CosemDateTime o) { // If a valid datetime can be created, use this to compare. // This will take deviation in to account. final LocalDateTime timeThis = this.asLocalDateTime(); final LocalDateTime timeOther = o.asLocalDateTime(); if (timeThis != null && timeOther != null) { return timeThis.compareTo(timeOther); }// w ww .ja va2 s. c o m // Otherwise compare date/time on an byte value basis. // Taking deviation into account is complex and bluebook // does not describe how that should even work with unspecified values. final int compDate = this.date.compareTo(o.date); if (compDate != 0) { return compDate; } final int compTime = this.time.compareTo(o.time); if (compTime != 0) { return compTime; } return 0; }
From source file:com.alliander.osgp.dto.valueobjects.smartmetering.CosemDateTimeDto.java
License:Open Source License
@Override public int compareTo(final CosemDateTimeDto o) { // If a valid datetime can be created, use this to compare. // This will take deviation in to account. final LocalDateTime timeThis = this.asLocalDateTime(); final LocalDateTime timeOther = o.asLocalDateTime(); if (timeThis != null && timeOther != null) { return timeThis.compareTo(timeOther); }//from w w w . j a va2 s . co m // Otherwise compare date/time on an byte value basis. // Taking deviation into account is complex and bluebook // does not describe how that should even work with unspecified values. final int compDate = this.date.compareTo(o.date); if (compDate != 0) { return compDate; } final int compTime = this.time.compareTo(o.time); if (compTime != 0) { return compTime; } return 0; }
From source file:com.axelor.apps.organisation.service.TaskService.java
License:Open Source License
/** * Mthode permettant de calculer la somme des dures de la liste de planning et * d'assigner la quantit, l'unit, et la date de fin la tche courante. * @param planningLineList La liste des lignes de planning * @param task La tche courante/*from w w w. ja v a2 s .co m*/ * @throws AxelorException Les units demands ne se trouvent pas dans la liste de conversion */ public LocalDateTime getTaskEndDate(Task task) throws AxelorException { LocalDateTime laterDate = task.getEndDateT(); if (task.getPlanningLineList() != null) { for (PlanningLine planningLine : task.getPlanningLineList()) { if (laterDate == null || laterDate.compareTo(planningLine.getToDateTime()) < 0) { laterDate = planningLine.getToDateTime(); } } } return laterDate; }
From source file:com.phloc.datetime.PDTUtils.java
License:Apache License
/** * <code>null</code> safe compare.<br> * Note: it has the same semantics as/*from ww w . j a v a2 s . com*/ * {@link com.phloc.commons.compare.CompareUtils#nullSafeCompare(Comparable, Comparable)} * except that the parameter class does not implement * {@link java.lang.Comparable} in a Generics-way! * * @param aDateTime1 * First object. May be <code>null</code>. * @param aDateTime2 * Second object. May be <code>null</code>. * @return -1, 0 or +1 */ public static int nullSafeCompare(@Nullable final LocalDateTime aDateTime1, @Nullable final LocalDateTime aDateTime2) { return aDateTime1 == aDateTime2 ? 0 : aDateTime1 == null ? -1 : aDateTime2 == null ? +1 : aDateTime1.compareTo(aDateTime2); }
From source file:com.phloc.datetime.PDTUtils.java
License:Apache License
public static boolean isGreater(@Nonnull final LocalDateTime aDateTime1, @Nonnull final LocalDateTime aDateTime2) { return aDateTime1.compareTo(aDateTime2) > 0; }
From source file:com.phloc.datetime.PDTUtils.java
License:Apache License
public static boolean isGreaterOrEqual(@Nonnull final LocalDateTime aDateTime1, @Nonnull final LocalDateTime aDateTime2) { return aDateTime1.compareTo(aDateTime2) >= 0; }
From source file:com.phloc.datetime.PDTUtils.java
License:Apache License
public static boolean isLess(@Nonnull final LocalDateTime aDateTime1, @Nonnull final LocalDateTime aDateTime2) { return aDateTime1.compareTo(aDateTime2) < 0; }
From source file:com.phloc.datetime.PDTUtils.java
License:Apache License
public static boolean isLessOrEqual(@Nonnull final LocalDateTime aDateTime1, @Nonnull final LocalDateTime aDateTime2) { return aDateTime1.compareTo(aDateTime2) <= 0; }
From source file:com.sonicle.webtop.calendar.Service.java
License:Open Source License
public void processGetPlanning(HttpServletRequest request, HttpServletResponse response, PrintWriter out) { CoreUserSettings cus = getEnv().getCoreUserSettings(); CoreManager core = WT.getCoreManager(); ArrayList<MapItem> items = new ArrayList<>(); Connection con = null;/*from w w w .j a v a 2s . c o m*/ try { String eventStartDate = ServletUtils.getStringParameter(request, "startDate", true); String eventEndDate = ServletUtils.getStringParameter(request, "endDate", true); String timezone = ServletUtils.getStringParameter(request, "timezone", true); JsEvent.Attendee.List attendees = ServletUtils.getObjectParameter(request, "attendees", new JsEvent.Attendee.List(), JsEvent.Attendee.List.class); //JsAttendeeList attendees = ServletUtils.getObjectParameter(request, "attendees", new JsAttendeeList(), JsAttendeeList.class); // Parses string parameters DateTimeZone eventTz = DateTimeZone.forID(timezone); DateTime eventStartDt = DateTimeUtils.parseYmdHmsWithZone(eventStartDate, eventTz); DateTime eventEndDt = DateTimeUtils.parseYmdHmsWithZone(eventEndDate, eventTz); UserProfile up = getEnv().getProfile(); DateTimeZone profileTz = up.getTimeZone(); LocalTime localStartTime = eventStartDt.toLocalTime(); LocalTime localEndTime = eventEndDt.toLocalTime(); LocalTime fromTime = DateTimeUtils.min(localStartTime, us.getWorkdayStart()); LocalTime toTime = DateTimeUtils.max(localEndTime, us.getWorkdayEnd()); // Defines useful date/time formatters DateTimeFormatter ymdhmFmt = DateTimeUtils.createYmdHmFormatter(); DateTimeFormatter tFmt = DateTimeUtils.createFormatter(cus.getShortTimeFormat()); DateTimeFormatter dFmt = DateTimeUtils.createFormatter(cus.getShortDateFormat()); ArrayList<String> spans = manager.generateTimeSpans(60, eventStartDt.toLocalDate(), eventEndDt.toLocalDate(), us.getWorkdayStart(), us.getWorkdayEnd(), profileTz); // Generates fields and columnsInfo dynamically ArrayList<FieldMeta> fields = new ArrayList<>(); ArrayList<GridColumnMeta> colsInfo = new ArrayList<>(); GridColumnMeta col = null; fields.add(new FieldMeta("recipient")); colsInfo.add(new GridColumnMeta("recipient")); for (String spanKey : spans) { LocalDateTime ldt = ymdhmFmt.parseLocalDateTime(spanKey); fields.add(new FieldMeta(spanKey)); col = new GridColumnMeta(spanKey, tFmt.print(ldt)); col.put("date", dFmt.print(ldt)); col.put("overlaps", (ldt.compareTo(eventStartDt.toLocalDateTime()) >= 0) && (ldt.compareTo(eventEndDt.toLocalDateTime()) < 0)); colsInfo.add(col); } // Collects attendees availability... OUser user = null; UserProfileId profileId = null; LinkedHashSet<String> busyHours = null; MapItem item = null; for (JsEvent.Attendee attendee : attendees) { item = new MapItem(); item.put("recipient", attendee.recipient); user = guessUserByAttendee(core, attendee.recipient); if (user != null) { profileId = new UserProfileId(user.getDomainId(), user.getUserId()); busyHours = manager.calculateAvailabilitySpans(60, profileId, eventStartDt.withTime(fromTime), eventEndDt.withTime(toTime), eventTz, true); for (String hourKey : spans) { item.put(hourKey, busyHours.contains(hourKey) ? "busy" : "free"); } } else { for (String spanKey : spans) { item.put(spanKey, "unknown"); } } items.add(item); } GridMetadata meta = new GridMetadata(true); meta.setFields(fields); meta.setColumnsInfo(colsInfo); new JsonResult(items, meta, items.size()).printTo(out); } catch (Exception ex) { logger.error("Error in GetPlanning", ex); new JsonResult(false, "Error").printTo(out); } finally { DbUtils.closeQuietly(con); } }
From source file:com.the.todo.model.ToDo.java
License:MIT License
@Override public int compareTo(ToDo todo) { if (todo == null) { throw new IllegalArgumentException(); }/* w w w. jav a 2 s . com*/ LocalDateTime currentTaskDate = getDateToCompare(this); LocalDateTime inputTaskDate = getDateToCompare(todo); boolean isSameDateAndTime = currentTaskDate.compareTo(inputTaskDate) == 0; boolean isSameType = this.getType().compareTo(todo.getType()) == 0; boolean isSamePriority = this.getPriority().compareTo(todo.getPriority()) == 0; if (isSamePriority) { if (isSameDateAndTime) { if (isSameType) { return this.getTitle().compareToIgnoreCase(todo.getTitle()); } else { if (this.getType() == Type.FLOATING) { return -1; } else if (todo.getType() == Type.FLOATING) { return 1; } else { return this.getType().compareTo(todo.getType()); } } } else { return currentTaskDate.compareTo(inputTaskDate); } } else { return this.getPriority().compareTo(todo.getPriority()); } }