mysql - Getting difference between two Timestamp objects in Java -


i'm working on project, it's parking , contains database. have variable timestamp time/date when car enter parking, , 1 when car on exit. want difference in hours (minute after every full hour new hour etc. 4 hours , 2 mins same 5 hours) can calculate price of service (hours multiply price per hour).

help me pls, , thank in advance

get difference in milliseconds , calculate below

long timediff = endtime.gettime() - starttime.gettime()  int hours = (int)math.ceil(timediff/1000*60*60) //in here converting milli seconds difference hours , if not exact number converting next integer 

Comments