/** * Convert a date to the specified time zone. * * @param x the date to convert * @param target the calendar with the target timezone * @return the milliseconds in UTC */ public static long convertToLocal(java.util.Date x, Calendar target) { if (target == null) { throw DbException.getInvalidValueException("calendar", null); } target = (Calendar) target.clone(); Calendar local = Calendar.getInstance(); synchronized (local) { local.setTime(x); convertTime(local, target); } return target.getTime().getTime(); }
/** * Returns the value of the specified column as a java.sql.Time using a * specified time zone. * * @param columnIndex (1,2,...) * @param calendar the calendar * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public Time getTime(int columnIndex, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("getTime(" + columnIndex + ", calendar)"); } return DateTimeUtils.convertTime(get(columnIndex), calendar); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as a java.sql.Time using a * specified time zone. * * @param columnLabel the column label * @param calendar the calendar * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public Time getTime(String columnLabel, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("getTime(" + StringUtils.quoteJavaString(columnLabel) + ", calendar)"); } return DateTimeUtils.convertTime(get(columnLabel), calendar); } catch (Exception e) { throw logAndConvert(e); } }
/** * Sets the time using a specified time zone. The value will be converted to * the local time zone. * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @param calendar the calendar * @throws SQLException if this object is closed */ @Override public void setTime(int parameterIndex, java.sql.Time x, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("setTime(" + parameterIndex + ", " + quoteTime(x) + ", calendar);"); } if (x == null) { setParameter(parameterIndex, ValueNull.INSTANCE); } else { setParameter(parameterIndex, DateTimeUtils.convertTime(x, calendar)); } } catch (Exception e) { throw logAndConvert(e); } }