Possible Duplicate:
Calculating the Difference Between Two Java Date Instances
I am not able to solve below problem please help me.That is i am adding existing time to some some more time (minutes ,seconds or hours).Iam not able to write bellow wt type I wrote i mention that is not given correct answer,
String allexam_end_time="18:59:00";//48540000
long oneminute=60000;
try{
SimpleDateFormat sdfkk = new SimpleDateFormat("hh:mm:ss");
Date reqEndtimekk = sdfkk.parse(allexam_end_time);
long total=reqEndtimekk.getTime()+oneminute;
System.out.println("TOtal miliseconds "+reqEndtimekk.getTime()+oneminute);
System.out.println("total---------"+total);
int s = (int)(total / 1000) % 60;
int m = (int)(total / (1000 * 60)) % 60;
int h= (int) (total / (1000 * 60 * 60)) % 24;
System.out.println(h+":"+m+":"+s);
}catch(Exception e){
}
Output
output is TOtal miliseconds4854000060000
total---------48600000
13:30:0
But I need answer that if added one minute means outputshould 19:00:00 How can solve?