Java LocalTime currentTimeIsBetween(LocalTime from, LocalTime to)

Here you can find the source of currentTimeIsBetween(LocalTime from, LocalTime to)

Description

Check if current time is between given local times

License

Open Source License

Parameter

Parameter Description
from Left border
to Right border

Return

Is current between?

Declaration

public static boolean currentTimeIsBetween(LocalTime from, LocalTime to) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.time.LocalTime;

public class Main {
    /**/*from  w w  w .  j a  va 2  s  . c om*/
     * Check if current time is between given local times
     * @param from      Left border
     * @param to        Right border
     * @return          Is current between?
     */
    public static boolean currentTimeIsBetween(LocalTime from, LocalTime to) {
        LocalTime current = LocalTime.now();

        if (from == null || to == null)
            return true;

        return (current.isAfter(from) && current.isBefore(to)) || current.equals(from) || current.equals(to);

    }
}

Related

  1. asDate(LocalTime localTime)
  2. convertLocalTimeToString(LocalTime time)
  3. deserializeLocalTime(String date)
  4. fastTimeWrite(LocalTime localTime)
  5. getTimeDiff(LocalTime start, LocalTime end)
  6. isBetween(LocalTime lt, LocalTime startTime, LocalTime endTime)