Source Code : Determine if an hour is between an interval
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
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));
}
}
Thank with us