code: public static Long toTimestamp(String dateStr, TimeZone tz) {
  		int length = dateStr.length();
  		String format;
  		if (length == 21) {
  			format = DEFAULT_DATETIME_FORMATS[1];
  		} else if (length == 22) {
  			format = DEFAULT_DATETIME_FORMATS[2];
  		} else if (length == 23) {
  			format = DEFAULT_DATETIME_FORMATS[3];
  		} else {
  			// otherwise fall back to the default
  			format = DEFAULT_DATETIME_FORMATS[0];
  		}
  		return toTimestamp(dateStr, format, tz);
  	}
docs: Parse date time string to timestamp based on the given time zone and
  "yyyy-MM-dd HH:mm:ss" format. Returns null if parsing failed.
  
  @param dateStr the date time string
  @param tz the time zone