tags:

views:

92

answers:

2

I'm retrieving two timestamps from a database (check_in and check_out). I need to compare the two to find out how many days have passed between the two timestamps. How can this be done in Java?

A: 

Just subtract check_out and check_in, and convert from whatever units you're in to days. Something like

//pseudo-code
diff_in_millis = Absolute Value Of ( check_out - check_in ) ;

diff_in_days = (diff_in_millis / 1000 ) * 60 * 60 * 24;
Amir Afghani