1. Description: Add a time difference to the previous period:
code example:
Date psd = sysdate ();
String workTimeP1 = Mapp.get ("work_time_")! = null? Mapp.get ("Work_time_"). ToString (): "0";
int News=integer.parseint (workTimeP1) *60;
Date ped=dateutils.addseconds (psd,news);
2. Calculation code for the time difference: take milliseconds as an example
public static int Secondsbetween (Date smdate,date bdate) throws Exception {
SimpleDateFormat sdf=new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"); Time format
Smdate=sdf.parse (Sdf.format (smdate));
Bdate=sdf.parse (Sdf.format (bdate));
Calendar cal = Calendar.getinstance ();
Cal.settime (smdate);
Long time1 = Cal.gettimeinmillis ();
Cal.settime (bdate);
Long time2 = Cal.gettimeinmillis ();
Long between_seconds= (time2-time1)/(1000);
Return Integer.parseint (string.valueof (between_seconds));
}
Tbpbc35 c35=c35list.get (0);
C35.setlotstarttime (c36mindate);//lot start time is the earliest start time of the schedule
C35.setlotendtime (c36maxdate);//lot end time is the latest end of the schedule
int Seconds=this.secondsbetween (C35.getlotstarttime (), C35.getlotendtime ());
int mintues=seconds/60;
BigDecimal mb=new BigDecimal (mintues);
C35.setworktotaltime (MB);
3. Addition of Time:
int ps = C36.getprodstartdate (). getseconds ();//Current Time of Huawei sec
int news = ps-betweendate;//Current time plus
Date s = c36.getprodstartdate ();//Current time
S.setseconds (news);
C36.setprodstartdate (s);
This article is from the "Ancient Yan" blog, please be sure to keep this source http://610201092.blog.51cto.com/7852003/1653629
Calculation of time in Java