getTimestamp(TimeZone tz) { /* ** Ingres dates are overloaded with 'empty' date, ** date only, timestamp and interval values. The ** first three types are handled explicitly below. ** Intervals will either cause an exception while ** attempting to parse the value or as the default ** action for an unrecognized format. */ try { if (value.Length == 0) // Empty date { /* ** Create a timstamp EPOCH value. If no timezone is ** provided, we can return the local epoch constant. ** Otherwise, the epoch value for the requested ** timezone must be generated. */ return((tz == null) ? SqlDates.getEpochTimestamp() : SqlDates.parseTimestamp(SqlDates.TS_EPOCH, tz)); } else if (value.Length == SqlDates.D_FMT.Length) // Date only { /* ** There is no time component, so convert to timestamp with ** a 0 time component for the requested/local timezone. */ DateTime date = (tz == null) ? SqlDates.parseDate(value, false) : SqlDates.parseDate(value, tz); return(date); } else if (value.Length == SqlDates.TS_FMT.Length) // Timestamp { /* ** Convert to GMT timestamp using TZ for current connection. */ DateTime ts = SqlDates.parseTimestamp(value, use_gmt); if (osql_dates && tz != null) { /* ** Effectively, we need to apply time difference ** between local and requested timezones. First, ** apply local TZ to get local timestamp. Then ** apply requested TZ to get desired GMT value. */ String str = SqlDates.formatTimestamp(ts, false); ts = SqlDates.parseTimestamp(str, tz); } return(ts); } else // Interval { /* ** Can't support intervals with Timestamp objects. */ throw SqlEx.get(ERR_GC401B_INVALID_DATE); } } catch (SqlEx ex) { /* ** Any parsing error is assumed to be caused by an interval. */ interval = true; throw ex; } } // getTimestamp