static public Date getDate ( String str , TimeZone tz , SFSession session ) throws SFException { try { long milliSecsSinceEpoch = Long . valueOf ( str ) * 86400000 ; SFTimestamp tsInUTC = SFTimestamp . fromDate ( new Date ( milliSecsSinceEpoch ) , 0 , TimeZone . getTimeZone ( "UTC" ) ) ; SFTimestamp tsInClientTZ = tsInUTC . moveToTimeZone ( tz ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "getDate: tz offset={}" , tsInClientTZ . getTimeZone ( ) . getOffset ( tsInClientTZ . getTime ( ) ) ) ; } // return the date adjusted to the JVM default time zone Date preDate = new Date ( tsInClientTZ . getTime ( ) ) ; // if date is on or before 1582-10-04, apply the difference // by (H-H/4-2) where H is the hundreds digit of the year according to: // http://en.wikipedia.org/wiki/Gregorian_calendar Date newDate = adjustDate ( preDate ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Adjust date from {} to {}" , preDate . toString ( ) , newDate . toString ( ) ) ; } return newDate ; } catch ( NumberFormatException ex ) { throw ( SFException ) IncidentUtil . generateIncidentV2WithException ( session , new SFException ( ErrorCode . INTERNAL_ERROR , "Invalid date value: " + str ) , null , null ) ; } }
Convert a date internal object to a Date object in specified timezone .