Java ZonedDateTime Calculate isBetweenTimesInclusive(ZonedDateTime dateTime, ZonedDateTime startDateTime, ZonedDateTime endDateTime)

Here you can find the source of isBetweenTimesInclusive(ZonedDateTime dateTime, ZonedDateTime startDateTime, ZonedDateTime endDateTime)

Description

is Between Times Inclusive

License

Apache License

Declaration

public static boolean isBetweenTimesInclusive(ZonedDateTime dateTime, ZonedDateTime startDateTime,
            ZonedDateTime endDateTime) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.time.ZonedDateTime;

public class Main {
    public static boolean isBetweenTimesInclusive(ZonedDateTime dateTime, ZonedDateTime startDateTime,
            ZonedDateTime endDateTime) {

        if (dateTime == null)
            return true;

        if (startDateTime == null) {
            if (endDateTime == null) {// Both startDate and endDate are null, so it's false
                return true;
            } else {// We only have the endDate, so any dateTime not after the endDateTime is true
                return !dateTime.isAfter(endDateTime);
            }/*www.j  av  a  2  s  .  c  om*/
        } else {
            if (endDateTime == null) {// We only have the startDateTime, so any dateTime not before the startDateTime is true
                return !dateTime.isBefore(startDateTime);
            } else {// We have both startDateTime and endDateTime, so any dateTime not before the startDate and not after endDateTime is true
                return !dateTime.isBefore(startDateTime) && !dateTime.isAfter(endDateTime);
            }
        }
    }
}

Related

  1. getStartOfWeek(ZoneId zoneId, ZonedDateTime time)
  2. getTime(ZonedDateTime zonedTime)
  3. getTimePath(Path dir, String ext, ZonedDateTime dateTime)
  4. getZonedDateTimeForComparison(TimeZone zone)
  5. holidaysInRange(ZonedDateTime startDate, ZonedDateTime endDate, List holidays)
  6. isoDateTime(ZonedDateTime zonedDateTime)
  7. mapToZonedDateTime(final Date date)
  8. max(ZonedDateTime a, ZonedDateTime b)
  9. oneDayLater(ZonedDateTime baseDate)