Calculate Time difference in Java


public static long checkTimeDifference(String time1,String time2){
     
         //time1 and time 2 must be in HH:mm:ss format

    SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
    Date date1;
    Date date2;
    long difference=0;
try {
date1 = format.parse(time1);
date2 = format.parse(time2);
difference = date2.getTime() - date1.getTime();
} catch (ParseException e) {
e.printStackTrace();
}
return difference;
   
    }

Popular posts from this blog

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Upload file on Google cloud storage using Java servlet on google app engine

Android: where to run keytool command in android