getTime(TimeZone tz) { String str = getString().Trim(); return((tz == null) ? SqlDates.parseTime(str, false) : SqlDates.parseTime(str, tz)); } // getTime
getTime(TimeZone tz) { /* ** Strip date component by re-formatting as time value. */ return(SqlDates.parseTime(SqlDates.formatTime(get(tz), false), false)); } // getTime
getTime(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 value.Length == SqlDates.D_FMT.Length) // Date only { /* ** There is no time component, so create a time 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.getEpochTime() : SqlDates.parseTime(SqlDates.T_EPOCH, tz)); } else if (value.Length == SqlDates.TS_FMT.Length) // Timestamp { /* ** Remove the date component but retain correct time: ** ** 1. Convert to GMT timestamp using TZ for current connection. ** 2. Re-format as time only using local TZ to get local time. ** 3. Generate Time value using requested/local TZ. */ DateTime ts = SqlDates.parseTimestamp(value, use_gmt); String str = SqlDates.formatTime(ts, false); return((osql_dates && tz != null) ? SqlDates.parseTime(str, tz) : SqlDates.parseTime(str, false)); } else // Interval { /* ** Can't support intervals with Time 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; } } // getTime
setTime(DateTime value, TimeZone tz) { // DateTime is never null //if ( value == null ) //setNull(); //else { /* ** The time is stored in GMT. Timezones are not applied to ** Ingres times since they are also stored in GMT. OpenSQL ** times are assumed to be in the client TZ, so timezones ** can be applied to store values for specific timezones. */ if (osql_dates && tz != null) { /* ** First retrieve the time in the desired TZ. */ String str = SqlDates.formatTime(value, tz); /* ** The local TZ will be applied, either by the driver or ** the gateway, during subsequent processing. We use the ** local TZ to save the desired value so as to cancel the ** future application of the local TZ. */ value = SqlDates.parseTime(str, false); } /* ** Produce the correct time value for the current connection. ** ** Ingres only partially supports time only values and adds ** the current date to such values. JDBC specifies that the ** date portion for time values should be set to the date ** epoch 1970-01-01. When the current date has a different ** daylight savings offset than the epoch, a one hour offset ** can occur because of the different GMT offsets applied by ** Java and Ingres. Due to these problems, format the time ** as a timestamp to ensure consistent processing. Note that ** formatTimestamp() takes a java.util.Date parameter of which ** java.sql.Time is a sub-class. */ setNotNull(); this.value = SqlDates.formatTimestamp(value, use_gmt); interval = false; } return; } // setTime
get(TimeZone tz) { DateTime time; switch (dbms_type) { case DBMS_TYPE_TIME: time = SqlDates.parseTime(value, true); time = time.ToLocalTime(); break; case DBMS_TYPE_TMWO: /* ** Interpret as local time using requested or default timezone. */ time = (tz != null) ? SqlDates.parseTime(value, tz) : SqlDates.parseTime(value, false); break; case DBMS_TYPE_TMTZ: /* ** TIME WITH TIMEZONE values are local with ** explicit timezone offset. */ time = SqlDates.parseTime(value, SqlDates.getTZ(timezone)); time = time.ToLocalTime(); break; default: // should never happen since constructor checked throw SqlEx.get(ERR_GC401B_INVALID_DATE); } // end switch if (nanos > 0) { TimeSpan span = new TimeSpan(nanos / 100L); // one tick = 100 nanos time += span; // add the nanos back in } return(time); } // get
getTime(TimeZone tz) { return((tz == null) ? SqlDates.parseTime(value.Trim(), false) : SqlDates.parseTime(value.Trim(), tz)); } // getTime