Here you can find the source of currentTimeIsBetween(LocalTime from, LocalTime to)
Parameter | Description |
---|---|
from | Left border |
to | Right border |
public static boolean currentTimeIsBetween(LocalTime from, LocalTime to)
//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); } }