public static Long toTimestamp ( String dateStr , String format , TimeZone tz ) { SimpleDateFormat formatter = FORMATTER_CACHE . get ( format ) ; formatter . setTimeZone ( tz ) ; try { return formatter . parse ( dateStr ) . getTime ( ) ; } catch ( ParseException e ) { return null ; } }
Parse date time string to timestamp based on the given time zone and format . Returns null if parsing failed .