getDate(TimeZone tz) { String str = getString().Trim(); return((tz == null) ? SqlDates.parseDate(str, false) : SqlDates.parseDate(str, tz)); } // getDate
getDate(TimeZone tz) { /* ** Strip time component by re-formatting as date value. */ return(SqlDates.parseDate(SqlDates.formatDate(get(tz), false), false)); } // getDate
get(TimeZone tz) { /* ** Dates should be independent of TZ, but JDBC date values ** are stored in UTC. Use the TZ provided to ensure the ** resulting UTC value represents the date in the desired ** TZ. Otherwise, the local default TZ is used. */ return((tz != null) ? SqlDates.parseDate(value, tz) : SqlDates.parseDate(value, false)); } // get
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
getDate(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 { /* ** Ingres permits zero length date literals or 'empty' ** dates. Since does not have any corresponding ** date/time concept, we use the date epoch. 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.getEpochDate() : SqlDates.parseDate(SqlDates.D_EPOCH, tz)); } else if (value.Length == SqlDates.D_FMT.Length) // Date only { /* ** The date is stored in GMT such as to have a 0 time for ** the target TZ (requested/local). */ return((tz == null) ? SqlDates.parseDate(value, false) : SqlDates.parseDate(value, tz)); } else if (value.Length == SqlDates.TS_FMT.Length) // Timestamp { /* ** Remove the time component but retain correct date: ** ** 1. Convert to GMT Timestamp using TZ for current connection. ** 2. Format as date only using local TZ to get local date. ** 3. Generate Date value using requested/local timezone. */ DateTime date = SqlDates.parseTimestamp(value, use_gmt); String str = SqlDates.formatDate(date, false); return((osql_dates && tz != null) ? SqlDates.parseDate(str, tz) : SqlDates.parseDate(str, false)); } else // Interval { /* ** Can't support intervals with Date 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; } } // getDate
getString() { String str; /* ** Ingres dates are overloaded with 'empty' date, ** date only, timestamp and interval values. The ** raw data string is returned for empty dates and ** intervals. Date only values and timestamps are ** parsed/formatted to validate and set timezone. ** Intervals will cause an exception if an attempt ** is made to parse the value or will be detected ** by a mis-match in expected string lengths. */ try { if (value.Length == 0) // Empty date { /* ** Return the empty date string. */ str = value; } else if (value.Length == SqlDates.D_FMT.Length) // Date only { /* ** Do conversion to check for valid format (in ** case this is an interval). Ingres dates are ** indepedent of timezone, so use local TZ. */ DateTime dt = SqlDates.parseDate(value, false); str = SqlDates.formatDate(dt, false); } else if (value.Length == SqlDates.TS_FMT.Length) // Timestamp { /* ** Convert to GMT using TZ for current connection ** and then to local time using local TZ. */ DateTime ts = SqlDates.parseTimestamp(value, use_gmt); str = SqlDates.formatTimestamp(ts, false); } else // Interval { /* ** Return the interval string and produce a warning. */ interval = true; str = value; } } catch (SqlEx) { /* ** Any parsing error is assumed to be caused by an interval. */ interval = true; str = value; } return(str); } // getString
getDate(TimeZone tz) { return((tz == null) ? SqlDates.parseDate(value.Trim(), false) : SqlDates.parseDate(value.Trim(), tz)); } // getDate