Java Code Examples for java.time.LocalDate#compareTo()
The following examples show how to use
java.time.LocalDate#compareTo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InDateRangeColumnConstraint.java From ghidra with Apache License 2.0 | 5 votes |
@Override public boolean accepts(LocalDate value, TableFilterContext context) { if (value == null) { return false; } return value.compareTo(getMinValue()) >= 0 && value.compareTo(getMaxValue()) <= 0; }
Example 2
Source File: BiopsyTreatmentResponseData.java From hmftools with GNU General Public License v3.0 | 5 votes |
@Override public int compareTo(@NotNull BiopsyTreatmentResponseData other) { LocalDate date1 = date(); LocalDate date2 = other.date(); if (date1 == null && date2 == null) { return 0; } else if (date1 == null) { return 1; } else if (date2 == null) { return -1; } else { return date1.compareTo(date2); } }
Example 3
Source File: JapaneseEra.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static sun.util.calendar.Era privateEraFrom(LocalDate isoDate) { for (int i = KNOWN_ERAS.length - 1; i > 0; i--) { JapaneseEra era = KNOWN_ERAS[i]; if (isoDate.compareTo(era.since) >= 0) { return ERA_CONFIG[i]; } } return null; }
Example 4
Source File: JapaneseEra.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static sun.util.calendar.Era privateEraFrom(LocalDate isoDate) { for (int i = KNOWN_ERAS.length - 1; i > 0; i--) { JapaneseEra era = KNOWN_ERAS[i]; if (isoDate.compareTo(era.since) >= 0) { return ERA_CONFIG[i]; } } return null; }
Example 5
Source File: JapaneseEra.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static sun.util.calendar.Era privateEraFrom(LocalDate isoDate) { for (int i = KNOWN_ERAS.length - 1; i > 0; i--) { JapaneseEra era = KNOWN_ERAS[i]; if (isoDate.compareTo(era.since) >= 0) { return ERA_CONFIG[i]; } } return null; }
Example 6
Source File: JapaneseEra.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Obtains an instance of {@code JapaneseEra} from a date. * * @param date the date, not null * @return the Era singleton, never null */ static JapaneseEra from(LocalDate date) { if (date.isBefore(MEIJI_6_ISODATE)) { throw new DateTimeException("JapaneseDate before Meiji 6 are not supported"); } for (int i = KNOWN_ERAS.length - 1; i > 0; i--) { JapaneseEra era = KNOWN_ERAS[i]; if (date.compareTo(era.since) >= 0) { return era; } } return null; }
Example 7
Source File: JapaneseEra.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Obtains an instance of {@code JapaneseEra} from a date. * * @param date the date, not null * @return the Era singleton, never null */ static JapaneseEra from(LocalDate date) { if (date.isBefore(MEIJI_6_ISODATE)) { throw new DateTimeException("JapaneseDate before Meiji 6 are not supported"); } for (int i = KNOWN_ERAS.length - 1; i > 0; i--) { JapaneseEra era = KNOWN_ERAS[i]; if (date.compareTo(era.since) >= 0) { return era; } } return null; }
Example 8
Source File: JapaneseEra.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
static sun.util.calendar.Era privateEraFrom(LocalDate isoDate) { for (int i = KNOWN_ERAS.length - 1; i > 0; i--) { JapaneseEra era = KNOWN_ERAS[i]; if (isoDate.compareTo(era.since) >= 0) { return ERA_CONFIG[i]; } } return null; }
Example 9
Source File: NotInDateRangeColumnConstraint.java From ghidra with Apache License 2.0 | 5 votes |
@Override public boolean accepts(LocalDate value, TableFilterContext context) { if (value == null) { return false; } return value.compareTo(getMinValue()) < 0 || value.compareTo(getMaxValue()) > 0; }
Example 10
Source File: PartnerServiceImpl.java From axelor-open-suite with GNU Affero General Public License v3.0 | 5 votes |
/** * Search for the sale price list for the current date in the partner. * * @param partner * @return the sale price list for the partner null if no active price list has been found */ @Override public PriceList getSalePriceList(Partner partner) { PartnerPriceList partnerPriceList = partner.getSalePartnerPriceList(); if (partnerPriceList == null) { return null; } Set<PriceList> priceListSet = partnerPriceList.getPriceListSet(); if (priceListSet == null) { return null; } LocalDate today = Beans.get(AppBaseService.class).getTodayDate(); List<PriceList> candidatePriceListList = new ArrayList<>(); for (PriceList priceList : priceListSet) { LocalDate beginDate = priceList.getApplicationBeginDate() != null ? priceList.getApplicationBeginDate() : LocalDate.MIN; LocalDate endDate = priceList.getApplicationEndDate() != null ? priceList.getApplicationEndDate() : LocalDate.MAX; if (beginDate.compareTo(today) <= 0 && today.compareTo(endDate) <= 0) { candidatePriceListList.add(priceList); } } // if we found multiple price list, then the user will have to select one if (candidatePriceListList.size() == 1) { return candidatePriceListList.get(0); } else { return null; } }
Example 11
Source File: JapaneseEra.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static sun.util.calendar.Era privateEraFrom(LocalDate isoDate) { for (int i = KNOWN_ERAS.length - 1; i > 0; i--) { JapaneseEra era = KNOWN_ERAS[i]; if (isoDate.compareTo(era.since) >= 0) { return ERA_CONFIG[i]; } } return null; }
Example 12
Source File: JapaneseEra.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
static sun.util.calendar.Era privateEraFrom(LocalDate isoDate) { for (int i = KNOWN_ERAS.length - 1; i > 0; i--) { JapaneseEra era = KNOWN_ERAS[i]; if (isoDate.compareTo(era.since) >= 0) { return ERA_CONFIG[i]; } } return null; }
Example 13
Source File: BattleLogController.java From logbook-kai with MIT License | 5 votes |
public IUnit getUnit() { LocalDate from = this.from.getValue(); LocalDate to = this.to.getValue(); if (from != null && to != null) { if (from.compareTo(to) <= 0) { return new BattleLogs.CustomUnit(from, to); } else { return new BattleLogs.CustomUnit(to, from); } } return null; }
Example 14
Source File: JapaneseEra.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Obtains an instance of {@code JapaneseEra} from a date. * * @param date the date, not null * @return the Era singleton, never null */ static JapaneseEra from(LocalDate date) { if (date.isBefore(MEIJI_6_ISODATE)) { throw new DateTimeException("JapaneseDate before Meiji 6 are not supported"); } for (int i = KNOWN_ERAS.length - 1; i > 0; i--) { JapaneseEra era = KNOWN_ERAS[i]; if (date.compareTo(era.since) >= 0) { return era; } } return null; }
Example 15
Source File: JapaneseEra.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Obtains an instance of {@code JapaneseEra} from a date. * * @param date the date, not null * @return the Era singleton, never null */ static JapaneseEra from(LocalDate date) { if (date.isBefore(MEIJI_6_ISODATE)) { throw new DateTimeException("JapaneseDate before Meiji 6 are not supported"); } for (int i = KNOWN_ERAS.length - 1; i > 0; i--) { JapaneseEra era = KNOWN_ERAS[i]; if (date.compareTo(era.since) >= 0) { return era; } } return null; }
Example 16
Source File: ExpenseServiceImpl.java From axelor-open-suite with GNU Affero General Public License v3.0 | 4 votes |
@Override public List<KilometricAllowParam> getListOfKilometricAllowParamVehicleFilter( ExpenseLine expenseLine, Expense expense) throws AxelorException { List<KilometricAllowParam> kilometricAllowParamList = new ArrayList<>(); if (expense == null) { return kilometricAllowParamList; } if (expense.getId() != null) { expense = expenseRepository.find(expense.getId()); } if (expense.getUser() != null && expense.getUser().getEmployee() == null) { return kilometricAllowParamList; } List<EmployeeVehicle> vehicleList = expense.getUser().getEmployee().getEmployeeVehicleList(); LocalDate expenseDate = expenseLine.getExpenseDate(); if (expenseDate == null) { throw new AxelorException( TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.KILOMETRIC_ALLOWANCE_NO_DATE_SELECTED)); } for (EmployeeVehicle vehicle : vehicleList) { if (vehicle.getKilometricAllowParam() == null) { break; } LocalDate startDate = vehicle.getStartDate(); LocalDate endDate = vehicle.getEndDate(); if ((startDate == null && (endDate == null || expenseDate.compareTo(endDate) <= 0)) || (endDate == null && (expenseDate.compareTo(startDate) >= 0 || (expenseDate.compareTo(startDate) >= 0 && expenseDate.compareTo(endDate) <= 0)))) { kilometricAllowParamList.add(vehicle.getKilometricAllowParam()); } } return kilometricAllowParamList; }
Example 17
Source File: LocalDateComparator.java From flink with Apache License 2.0 | 4 votes |
@Override public int compare(LocalDate first, LocalDate second) { int cmp = first.compareTo(second); return ascendingComparison ? cmp : -cmp; }
Example 18
Source File: DayCountConvention_ACT_ACT_YEARFRAC.java From finmath-lib with Apache License 2.0 | 4 votes |
@Override public double getDaycountFraction(final LocalDate startDate, final LocalDate endDate) { if(startDate.isAfter(endDate)) { return -getDaycountFraction(endDate,startDate); } /* * Determine the denominator of act/act. */ double denominator; final LocalDate startDatePlusOneYear = startDate.plusYears(1); if(endDate.isAfter(startDatePlusOneYear)) { /* * The following method applies, if the interval spans more than one year: * fraction = actual number of days / average number of days per year. */ final LocalDate startDateYearStart = startDate.withDayOfYear(1); final LocalDate endDateYearEnd = endDate.withDayOfYear(endDate.lengthOfYear()).plusDays(1); final double spannedYears = endDate.getYear() - startDate.getYear() + 1; denominator = getDaycount(startDateYearStart, endDateYearEnd) / spannedYears; } else { final boolean isStartLeapYear = startDate.isLeapYear(); final boolean isEndLeapYear = endDate.isLeapYear(); /* * If the start and end span less or equal one year: * If start and end fall in a leap year, use ACT/366. */ if(isStartLeapYear && isEndLeapYear) { denominator = 366.0; } else /* * If the start and end span less or equal one year: * If either falls in a leap year and Feb 29th of that leap year lies in between start and end (or is equal to start or end), use ACT/366. */ if(isStartLeapYear || isEndLeapYear) { // Get February 29th of the respective leap year final LocalDate leapYearsFeb29th = isStartLeapYear ? LocalDate.of(startDate.getYear(), Month.FEBRUARY, 29) : LocalDate.of(endDate.getYear(), Month.FEBRUARY, 29); // Check position of February 29th if(startDate.compareTo(leapYearsFeb29th) <= 0 && endDate.compareTo(leapYearsFeb29th) >= 0) { denominator = 366.0; } else { denominator = 365.0; } } else { /* * If the start and end span less or equal one year: * If none of the above applies, use denominator = ACT/365. */ denominator = 365.0; } } final double daycountFraction = getDaycount(startDate, endDate) / denominator; return daycountFraction; }
Example 19
Source File: LocalDateType.java From jdmn with Apache License 2.0 | 4 votes |
protected int compare(LocalDate first, LocalDate second) { return first.compareTo(second); }
Example 20
Source File: TurboMilestone.java From HubTurbo with GNU Lesser General Public License v3.0 | 3 votes |
/** * Returns a stable TurboMilestone comparator by due date. * <p> * Open milestones without due date are considered to have a due date very far in the future. On the contrary, * closed milestones without due date are considered to have a due date very far in the past. * <p> * Milestones with due dates are considered in between, considered according to their due dates. */ public static Comparator<TurboMilestone> getDueDateComparator() { return (a, b) -> { LocalDate aDueDate = a.getDueDate().orElse(a.isOpen() ? LocalDate.MAX : LocalDate.MIN); LocalDate bDueDate = b.getDueDate().orElse(b.isOpen() ? LocalDate.MAX : LocalDate.MIN); return aDueDate.compareTo(bDueDate); }; }