private long getTime ( Date start1 , Date end1 , Date start2 , Date end2 ) { long total = 0 ; if ( start1 != null && end1 != null && start2 != null && end2 != null ) { long start ; long end ; if ( start1 . getTime ( ) < start2 . getTime ( ) ) { start = start2 . getTime ( ) ; } else { start = start1 . getTime ( ) ; } if ( end1 . getTime ( ) < end2 . getTime ( ) ) { end = end1 . getTime ( ) ; } else { end = end2 . getTime ( ) ; } if ( start < end ) { total = end - start ; } } return ( total ) ; }
This method returns the length of overlapping time between two time ranges .