Java LocalDate Calculate getMax(@Nonnull final LocalDate aDate1, @Nonnull final LocalDate aDate2)

Here you can find the source of getMax(@Nonnull final LocalDate aDate1, @Nonnull final LocalDate aDate2)

Description

get Max

License

Apache License

Declaration

@Nonnull
    public static LocalDate getMax(@Nonnull final LocalDate aDate1,
            @Nonnull final LocalDate aDate2) 

Method Source Code

//package com.java2s;
/**/*  ww  w.  ja v  a2s  .  co m*/
 * Copyright (C) 2014-2017 Philip Helger (www.helger.com)
 * philip[at]helger[dot]com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

import java.time.OffsetDateTime;
import java.time.ZonedDateTime;

import javax.annotation.Nonnull;

public class Main {
    @Nonnull
    public static LocalDate getMax(@Nonnull final LocalDate aDate1,
            @Nonnull final LocalDate aDate2) {
        return aDate1.isAfter(aDate2) ? aDate1 : aDate2;
    }

    @Nonnull
    public static LocalTime getMax(@Nonnull final LocalTime aTime1,
            @Nonnull final LocalTime aTime2) {
        return aTime1.isAfter(aTime2) ? aTime1 : aTime2;
    }

    @Nonnull
    public static LocalDateTime getMax(
            @Nonnull final LocalDateTime aDateTime1,
            @Nonnull final LocalDateTime aDateTime2) {
        return aDateTime1.isAfter(aDateTime2) ? aDateTime1 : aDateTime2;
    }

    @Nonnull
    public static ZonedDateTime getMax(
            @Nonnull final ZonedDateTime aDateTime1,
            @Nonnull final ZonedDateTime aDateTime2) {
        return aDateTime1.isAfter(aDateTime2) ? aDateTime1 : aDateTime2;
    }

    @Nonnull
    public static OffsetDateTime getMax(
            @Nonnull final OffsetDateTime aDateTime1,
            @Nonnull final OffsetDateTime aDateTime2) {
        return aDateTime1.isAfter(aDateTime2) ? aDateTime1 : aDateTime2;
    }
}

Related

  1. getFirstDayOfTheMonth(final LocalDate date)
  2. getLastDayInMonth(LocalDate localDate)
  3. getLastDayOfTheQuarter(final LocalDate date)
  4. getLocalDateBydayAndWeek(LocalDate localDate, int weekNumber, int dayNumber)
  5. getLrsLocalDate(String lbdcDate)
  6. getNextNoWeekedDay(LocalDate today)
  7. getQuarterBounds(final LocalDate date)
  8. getTimeDifferenceInDays(LocalDate to)
  9. getTodayAsLocalDate()