Example usage for java.time LocalDate MAX

List of usage examples for java.time LocalDate MAX

Introduction

In this page you can find the example usage for java.time LocalDate MAX.

Prototype

LocalDate MAX

To view the source code for java.time LocalDate MAX.

Click Source Link

Document

The maximum supported LocalDate , '+999999999-12-31'.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalDate a = LocalDate.MAX;

    System.out.println(a);
}

From source file:Main.java

public static void main(String[] args) {
    System.out.println(getElapsedYears(LocalDate.MAX, LocalDate.MIN));
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate february20th = LocalDate.of(2014, Month.FEBRUARY, 20);
    System.out.println(february20th);
    System.out.println(LocalDate.from(february20th.plus(15, ChronoUnit.YEARS))); // 2029-02-20
    System.out.println(LocalDate.MAX);
    System.out.println(LocalDate.MIN);

    System.out.println(LocalTime.MIDNIGHT); // 00:00
    System.out.println(LocalTime.NOON); // 12:00
    System.out.println(LocalTime.of(23, 12, 30, 500)); // 23:12:30.000000500
    System.out.println(LocalTime.now()); // 00:40:34.110
    System.out.println(LocalTime.ofSecondOfDay(11 * 60 * 60)); // 11:00
    System.out.println(LocalTime.from(LocalTime.MIDNIGHT.plusHours(4))); // 04:00
    System.out.println(LocalTime.MIN);
    System.out.println(LocalTime.MAX);

    System.out.println(LocalDateTime.of(2014, 2, 15, 12, 30, 50, 200)); // 2014-02-15T12:30:50.000000200
    System.out.println(LocalDateTime.now()); // 2014-02-28T17:28:21.002
    System.out.println(LocalDateTime.from(LocalDateTime.of(2014, 2, 15, 12, 30, 40, 500).plusHours(19))); // 2014-02-16T07:30:40.000000500
    System.out.println(LocalDateTime.MAX);
}

From source file:org.silverpeas.core.date.Period.java

/**
 * Creates a new period of time between the two non null specified dates. The period is spreading
 * over all the day(s) between the specified inclusive start day and the exclusive end day; the
 * period is expressed in days. For example, a period between 2016-12-15 and 2016-12-17 means the
 * period is spreading over two days (2016-12-15 and 2016-12-16).
 * @param startDay the start day of the period. It defines the inclusive date at which the
 * period starts.//  w ww  .ja  v a 2 s  . c o  m
 * @param endDay the end day of the period. It defines the exclusive date at which the period
 * ends. The end date must be the same or after the start date. An end date equal to the start
 * date means the period is spanning all the day of the start date; it is equivalent to an end
 * date being one day after the start date.
 * @return the period of days between the two specified dates.
 */
public static Period between(LocalDate startDay, LocalDate endDay) {
    checkPeriod(startDay, endDay);
    Period period = new Period();
    period.startDateTime = startDay == LocalDate.MIN ? OffsetDateTime.MIN
            : startDay.atStartOfDay(ZoneOffset.UTC).toOffsetDateTime();
    period.endDateTime = endDay == LocalDate.MAX ? OffsetDateTime.MAX
            : endDay.atStartOfDay(ZoneOffset.UTC).toOffsetDateTime();
    if (startDay.isEqual(endDay)) {
        period.endDateTime = period.endDateTime.plusDays(1);
    }
    period.inDays = true;
    return period;
}

From source file:org.silverpeas.core.date.Period.java

/**
 * Creates a new period of time between the two specified date or datetime.
 * If date parameters are instances of {@link LocalDate}, take a look at method
 * {@link #betweenNullable(Temporal, Temporal)} (LocalDate, LocalDate)}.
 * If date parameters are instances of {@link OffsetDateTime}, take a look at method
 * {@link #betweenNullable(Temporal, Temporal)} (OffsetDateTime, OffsetDateTime)}.
 * If both date parameters are null, then a period between {@link LocalDate#MIN} and
 * {@link LocalDate#MAX} is returned unless those parameters are explicitly typed; for example:
 * {@code Period.betweenNullable((OffsetDateTime) null, null)}
 * @param start the start of the period. It defines the inclusive date or datetime at which the
 * period starts. If it is null then the minimum temporal (date or datetime) is taken.
 * @param end the end day of the period. It defines the exclusive date or the exclusive datetime
 * at which the period ends. The end date must be the same or after the start date. An end date
 * equal to the start date means the period is spanning all the day; it is equivalent to an end
 * date being one day after the start date. If It is null then the maximum temporal (date or
 * datetime) is taken./*from  ww  w .  j  a  v  a  2s .co  m*/
 * @return the period of days between the two specified dates.
 * @throws IllegalArgumentException if date parameters are not both {@link LocalDate} or
 * {@link OffsetDateTime} instances.
 * @see LocalDate#MIN for the minimum supported date.
 * @see OffsetDateTime#MIN for the maximum supported date.
 * @see LocalDate#MAX for the maximum supported datetime.
 * @see OffsetDateTime#MAX for the maximum supported datetime.
 */
public static Period betweenNullable(java.time.temporal.Temporal start, java.time.temporal.Temporal end) {
    if (start == null && end == null) {
        return betweenNullable(LocalDate.MIN, LocalDate.MAX);
    }
    if (start != null && end != null) {
        // we ensure start and end are of the same type
        return between(start, end);
    }
    if (start instanceof LocalDate || end instanceof LocalDate) {
        return betweenNullable(minOrDate(start), maxOrDate(end));
    } else if (start instanceof OffsetDateTime || end instanceof OffsetDateTime) {
        return betweenNullable(minOrDateTime(start), maxOrDateTime(end));
    }
    throw new IllegalArgumentException(
            "Temporal parameters must be either of type LocalDate or OffsetDateTime");
}

From source file:org.silverpeas.core.date.Period.java

private static LocalDate maxOrDate(final Temporal date) {
    return date == null ? LocalDate.MAX : asLocalDate(date);
}