public static boolean sameDay ( Date dateOne , Date dateTwo ) { if ( ( dateOne == null ) || ( dateTwo == null ) ) { return false ; } Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( dateOne ) ; int year = cal . get ( Calendar . YEAR ) ; int day = cal . get ( Calendar . DAY_OF_YEAR ) ; cal . setTime ( dateTwo ) ; int year2 = cal . get ( Calendar . YEAR ) ; int day2 = cal . get ( Calendar . DAY_OF_YEAR ) ; return ( ( year == year2 ) && ( day == day2 ) ) ; }
Test to see if two dates are in the same day of year