Home > Back-end >  For calculating the overall running time and finally start time and end time of the algorithm
For calculating the overall running time and finally start time and end time of the algorithm

Time:01-09

Calculate light running total length, and finally turn on the light and turn off the light time.
Description: every 10 minutes to a data, if it is true, said the current time to a time before is turn on the light of the
 
@ Data
Public class Dat {
String date;//the current time
A Boolean flag.//whether to turn on the light

Public Dat (String date, Boolean flag) {
this.date=date;
. This flag=flag;
}
}
//calculate the length of the two time points interval
Public int getLenTime (String start, String end) {
Int st=Integer. ParseInt (end) the substring (3, 5));
Int en=Integer. ParseInt (start. The substring (3, 5));
Int res=(en - st + 60) % 60;
return res;
}

Public void test03 () {
Dat dat01=new Dat (" 11 ", true);
Dat dat02=new Dat (" "", true);//10 true within the former point to the current point in time is turn on the light
Dat dat03=new Dat (" 11 ", false);
Dat dat04=new Dat (" faith ", false);
Dat dat05=new Dat (" at ", true);//9
Dat dat06=new Dat (" 11:50 ", true);//10
Dat dat07=new Dat (" 12:00 ", true);//10
Dat dat08=new Dat (" and ", true);//11
Dat dat09=new Dat (" silla ", false);
Dat dat10=new Dat (" 12:30 ", false);

//dat01 dat02, dat03 dat04, dat05, dat06, dat07, dat08, dat09, dat10
List Dats=Lists. NewArrayList (dat01 dat02, dat03, dat04, dat05, dat06, dat07, dat08, dat09, dat10);

Results://the last need
//a light running time: 50
//the last light running time: forces from the cloud to
  • Related