Determine if an hour is between an interval
import java.text.SimpleDateFormat; public class Main{ static String HOUR_FORMAT = "HH:mm"; static SimpleDateFormat sdfHour = new SimpleDateFormat(HOUR_FORMAT); public static boolean isHourInInterval(String target, String start, String end) { return ((target.compareTo(start) >= 0)&& (target.compareTo(end) <= 0)); } public static void main (String[] args) { String now = "12"; String start = "14:00"; String end = "14:26"; System. out.println(now + " between " + start + "-" + end + "?"); System. out.println(isHourInInterval(now,start,end)); } }