public Date toDate ( Object date ) { Date d = null ; if ( null != date ) { if ( date instanceof Date ) { d = ( Date ) date ; } else if ( date instanceof Long ) { d = new Date ( ( ( Long ) date ) . longValue ( ) ) ; } else { try { long l = Long . parseLong ( date . toString ( ) ) ; d = new Date ( l ) ; } catch ( Exception e ) { // do nothing, just let d remain null } } } return d ; }
Converts the provided object to a date if possible .