当前位置: 首页>>代码示例>>Java>>正文


Java LocalDate.isBefore方法代码示例

本文整理汇总了Java中java.time.LocalDate.isBefore方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDate.isBefore方法的具体用法?Java LocalDate.isBefore怎么用?Java LocalDate.isBefore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.LocalDate的用法示例。


在下文中一共展示了LocalDate.isBefore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.time.LocalDate; //导入方法依赖的package包/类
public static void main(String[] args) {
    /* Read and save input as LocalDates */
    Scanner scan = new Scanner(System.in);
    LocalDate returnDate = readDate(scan);
    LocalDate expectDate = readDate(scan);
    scan.close();
    
    /* Calculate fine */
    int fine;
    if (returnDate.isEqual(expectDate) || returnDate.isBefore(expectDate)) {
        fine = 0;
    } else if (returnDate.getMonth() == expectDate.getMonth() && returnDate.getYear() == expectDate.getYear()) {
        fine = 15 * (returnDate.getDayOfMonth() - expectDate.getDayOfMonth());
    } else if (returnDate.getYear() == expectDate.getYear()) {
        fine = 500 * (returnDate.getMonthValue() - expectDate.getMonthValue());
    } else {
        fine = 10000;
    }
    System.out.println(fine);
}
 
开发者ID:rshaghoulian,项目名称:HackerRank_solutions,代码行数:21,代码来源:Solution.java

示例2: split

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * Splits the given period into multiple slices of one month long.
 *
 * @param start the start of the period.
 * @param end   the end of the period.
 * @return The list of slices result of the splitting.
 */
public static List<Slice> split(LocalDate start, LocalDate end) {
    Objects.requireNonNull(start);
    Objects.requireNonNull(end);
    Preconditions.checkArgument(!start.isAfter(end));

    List<Slice> slices = Lists.newArrayList();

    LocalDate startOfMonth = start.withDayOfMonth(1);
    LocalDate endOfMonth = YearMonth.from(end).atEndOfMonth();

    do {
        slices.add(new Slice(startOfMonth, YearMonth.from(startOfMonth).atEndOfMonth()));
        startOfMonth = startOfMonth.plus(1, ChronoUnit.MONTHS);
    }
    while (startOfMonth.isBefore(endOfMonth) || startOfMonth.isEqual(endOfMonth));

    return slices;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:26,代码来源:Slice.java

示例3: onCheckOutDateSelected

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * Validates the checkout date to ensure that it is at least one day after the checkin date.
 *
 * If it isn't, disables the room search button until it is.
 */
@FXML
private void onCheckOutDateSelected() {
    LocalDate checkOutDate = checkOutDatePicker.getValue();
    LocalDate checkInDate = checkInDatePicker.getValue();
    if(checkOutDate.isBefore(checkInDate) || checkOutDate.isEqual(checkInDate)) {
        checkOutDatePicker.getStyleClass().add("invalidField");
        checkOutDatePicker.setTooltip(
            new Tooltip("Checkout date cannot be on or before checkin date!")
        );
        findAvailableRoomsButton.setDisable(true);
    } else {
        checkOutDatePicker.getStyleClass().remove("invalidField");
        checkOutDatePicker.setTooltip(null);
        findAvailableRoomsButton.setDisable(false);
    }
    roomSearchResults.clear();
}
 
开发者ID:maillouxc,项目名称:git-rekt,代码行数:23,代码来源:BrowseRoomsScreenController.java

示例4: isShowingTimeMarker

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
protected boolean isShowingTimeMarker() {
    WeekDayView dayView = getSkinnable();
    WeekView weekView = dayView.getWeekView();

    if (weekView != null) {
        LocalDate today = getSkinnable().getToday();

        LocalDate weekStart = weekView.getStartDate();
        LocalDate weekEnd = weekView.getEndDate();

        return !(weekStart.isAfter(today) || weekEnd.isBefore(today));

    }

    return false;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:18,代码来源:WeekDayViewSkin.java

示例5: testRangeOfLocalDates

import java.time.LocalDate; //导入方法依赖的package包/类
@Test(dataProvider = "localDateRanges")
public void testRangeOfLocalDates(LocalDate start, LocalDate end, Period step, boolean parallel) {
    final Range<LocalDate> range = Range.of(start, end, step);
    final Array<LocalDate> array = range.toArray(parallel);
    final boolean ascend = start.isBefore(end);
    final int expectedLength = (int)Math.ceil(Math.abs((double)ChronoUnit.DAYS.between(start, end)) / (double)step.getDays());
    Assert.assertEquals(array.length(), expectedLength);
    Assert.assertEquals(array.typeCode(), ArrayType.LOCAL_DATE);
    Assert.assertTrue(!array.style().isSparse());
    Assert.assertEquals(range.start(), start, "The range start");
    Assert.assertEquals(range.end(), end, "The range end");
    LocalDate expected = null;
    for (int i=0; i<array.length(); ++i) {
        final LocalDate actual = array.getValue(i);
        expected = expected == null ? start : ascend ? expected.plus(step) : expected.minus(step);
        Assert.assertEquals(actual, expected, "Value matches at " + i);
        Assert.assertTrue(ascend ? actual.compareTo(start) >=0 && actual.isBefore(end) : actual.compareTo(start) <= 0 && actual.isAfter(end), "Value in bounds at " + i);
    }
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:20,代码来源:RangeBasicTests.java

示例6: addEntryToResult

import java.time.LocalDate; //导入方法依赖的package包/类
private void addEntryToResult(Map<LocalDate, List<Entry<?>>> result, Entry<?> entry, LocalDate startDate, LocalDate endDate) {
    LocalDate entryStartDate = entry.getStartDate();
    LocalDate entryEndDate = entry.getEndDate();

    // entry does not intersect with time interval
    if (entryEndDate.isBefore(startDate) || entryStartDate.isAfter(endDate)) {
        return;
    }

    if (entryStartDate.isAfter(startDate)) {
        startDate = entryStartDate;
    }

    if (entryEndDate.isBefore(endDate)) {
        endDate = entryEndDate;
    }

    LocalDate date = startDate;
    do {
        result.computeIfAbsent(date, it -> new ArrayList<>()).add(entry);
        date = date.plusDays(1);
    } while (!date.isAfter(endDate));
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:24,代码来源:Calendar.java

示例7: updateSelectedDates

import java.time.LocalDate; //导入方法依赖的package包/类
private void updateSelectedDates() {
    List<LocalDate> dates = new ArrayList<>();

    LocalDate start = getSkinnable().getPageStartDate();

    do {
        dates.add(start);
        start = start.plusDays(1);
    }
    while (start.isBefore(getSkinnable().getPageEndDate()) || start.isEqual(getSkinnable().getPageEndDate()));

    calendarOne.getSelectedDates().clear();
    calendarOne.getSelectedDates().addAll(dates);

    calendarTwo.getSelectedDates().clear();
    calendarTwo.getSelectedDates().addAll(dates);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:18,代码来源:PrintablePageSkin.java

示例8: isValid

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public boolean isValid(LocalDate localDate, ConstraintValidatorContext cxt) {
    // Another validator should check for this if required
    if (localDate == null) {
        return true;
    }

    return !localDate.isBefore(LocalDate.now());
}
 
开发者ID:hmcts,项目名称:cmc-claim-store,代码行数:10,代码来源:DateNotInThePastConstraintValidator.java

示例9: getDateDiff

import java.time.LocalDate; //导入方法依赖的package包/类
private DateCalculatorResult getDateDiff(final DateToken startDateToken, final Token thirdToken) {
    LocalDate one = startDateToken.getValue();
    LocalDate two = ((DateToken) thirdToken).getValue();
    return (one.isBefore(two))
            ? new DateCalculatorResult(Period.between(one, two))
            : new DateCalculatorResult(Period.between(two, one));
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:8,代码来源:DateCalculator.java

示例10: from

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:JapaneseEra.java

示例11: JapaneseDate

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * Creates an instance from an ISO date.
 *
 * @param isoDate  the standard local date, validated not null
 */
JapaneseDate(LocalDate isoDate) {
    if (isoDate.isBefore(MEIJI_6_ISODATE)) {
        throw new DateTimeException("JapaneseDate before Meiji 6 is not supported");
    }
    LocalGregorianCalendar.Date jdate = toPrivateJapaneseDate(isoDate);
    this.era = JapaneseEra.toJapaneseEra(jdate.getEra());
    this.yearOfEra = jdate.getYear();
    this.isoDate = isoDate;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:JapaneseDate.java

示例12: JapaneseDate

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * Constructs a {@code JapaneseDate}. This constructor does NOT validate the given parameters,
 * and {@code era} and {@code year} must agree with {@code isoDate}.
 *
 * @param era  the era, validated not null
 * @param year  the year-of-era, validated
 * @param isoDate  the standard local date, validated not null
 */
JapaneseDate(JapaneseEra era, int year, LocalDate isoDate) {
    if (isoDate.isBefore(MEIJI_6_ISODATE)) {
        throw new DateTimeException("JapaneseDate before Meiji 6 is not supported");
    }
    this.era = era;
    this.yearOfEra = year;
    this.isoDate = isoDate;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:JapaneseDate.java

示例13: bepaalEersteSelectiedatum

import java.time.LocalDate; //导入方法依赖的package包/类
private static BerekendeEersteSelectieDatum bepaalEersteSelectiedatum(LocalDate eersteSelectieDatum, LocalDate beginDatum,
                                                                      Dienst dienst, ChronoUnit chronoUnit) {
    LocalDate nieuweEersteSelectiedatum = eersteSelectieDatum;
    int aantalPeriodes = 0;
    while (nieuweEersteSelectiedatum.isBefore(beginDatum) && chronoUnit != null && dienst.getEenheidSelectieInterval() != null) {
        nieuweEersteSelectiedatum = nieuweEersteSelectiedatum.plus(dienst.getSelectieInterval(), chronoUnit);
        aantalPeriodes++;
    }
    return new BerekendeEersteSelectieDatum(nieuweEersteSelectiedatum, aantalPeriodes);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:11,代码来源:SelectieTaakBerekenServiceImpl.java

示例14: select

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public void select(LocalDate date) {
    if (date != null) {
        if (rangeStart == null) {
            model.selectedDates.setAll(date);
            model.lastSelected = date;
            rangeStart = date;
            rangeEnd = date;
        } else {
            if (date.equals(rangeStart.plusDays(-1)) || date.equals(rangeEnd.plusDays(1))) {
                model.selectedDates.add(date);
                model.lastSelected = date;

                if (date.isAfter(rangeEnd)) {
                    rangeEnd = date;
                }

                if (date.isBefore(rangeStart)) {
                    rangeStart = date;
                }
            } else {
                rangeStart = null;
                rangeEnd = null;
                select(date);
            }
        }
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:29,代码来源:DateSelectionModel.java

示例15: isIntersecting

import java.time.LocalDate; //导入方法依赖的package包/类
private boolean isIntersecting(LocalDate start, LocalDate end) {
    if ((start.isBefore(rangeStart) || start.isEqual(rangeStart)) && (end.isAfter(rangeEnd) || end.isEqual(rangeEnd))) {
        return true;
    }

    if ((start.isEqual(rangeStart) || start.isAfter(rangeStart)) && (start.isBefore(rangeEnd) || start.isEqual(rangeEnd))) {
        return true;
    }

    return (end.isEqual(rangeStart) || end.isAfter(rangeStart)) && (end.isBefore(rangeEnd) || end.isEqual(rangeEnd));

}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:13,代码来源:DateSelectionModel.java


注:本文中的java.time.LocalDate.isBefore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。