public static TimeDuration minus ( final Date lhs , final Date rhs ) { long milliseconds = lhs . getTime ( ) - rhs . getTime ( ) ; long days = milliseconds / ( 24 * 60 * 60 * 1000 ) ; milliseconds -= days * 24 * 60 * 60 * 1000 ; int hours = ( int ) ( milliseconds / ( 60 * 60 * 1000 ) ) ; milliseconds -= hours * 60 * 60 * 1000 ; int minutes = ( int ) ( milliseconds / ( 60 * 1000 ) ) ; milliseconds -= minutes * 60 * 1000 ; int seconds = ( int ) ( milliseconds / 1000 ) ; milliseconds -= seconds * 1000 ; return new TimeDuration ( ( int ) days , hours , minutes , seconds , ( int ) milliseconds ) ; }
Subtract one date from the other .