DateFormat df = new SimpleDateFormat("hh:mm");
try{
long mintime=df.parse("00:00").getTime();
long maxtime=df.parse("24:00").getTime();
long[] time1={df.parse(zone1[0]).getTime(),df.parse(zone1[1]).getTime()};
long[] time2={df.parse(zone2[0]).getTime(),df.parse(zone2[1]).getTime()};
long[] acttime={df.parse(actzone[0]).getTime(),df.parse(actzone[1]).getTime()};
if(time1[0]>=time1[1]||time1[0]<=mintime||time1[1]>=maxtime)
System.out.println("Operation range one is illegal");
if(time2[0]>=time2[1]||time2[0]<=mintime||time2[1]>=maxtime)
System.out.println("Operation range two is illegal");
if(acttime[0]>=acttime[1]||acttime[0]<=mintime||acttime[1]>=maxtime)
System.out.println("The peak period interval is illegal");
boolean ifLegal=false;
if(acttime[0]>=time1[0]&&acttime[1]<=time1[1])
ifLegal=true;
if(acttime[0]>=time2[0]&&acttime[1]<=time2[1])
ifLegal=true;
if(ifLegal)
System.out.println("info: Peak period range is legal");
else
System.out.println("warn: The peak period interval is illegal");
}catch(Exception e){
e.printStackTrace();
}