/** * @see CommonTS#setOffset(int) * @throws DataTypeException if the value is incorrectly formatted. If validation is enabled, this * exception should be thrown at setValue(), but if not, detailed parsing may be deferred until * this method is called. */ public void setOffset(int signedOffset) throws DataTypeException { getDetail().setOffset(signedOffset); }
/** * @see CommonTS#setOffset(int) * @throws DataTypeException if the value is incorrectly formatted. If validation is enabled, this * exception should be thrown at setValue(), but if not, detailed parsing may be deferred until * this method is called. */ public void setOffset(int signedOffset) throws DataTypeException { getDetail().setOffset(signedOffset); }
/** * Convenience setter which sets the value using a {@link Calendar} object. * Passing in <code>null</code> clears any existing value. * * Note: Sets fields using precision up to the millisecond, including timezone offset * * @param theCalendar The calendar object from which to retrieve values * @since 1.1 */ public void setValue(Calendar theCalendar) throws DataTypeException { if (theCalendar == null) { setValue((String)null); return; } int yr = theCalendar.get(Calendar.YEAR); int mnth = theCalendar.get(Calendar.MONTH) + 1; int dy = theCalendar.get(Calendar.DATE); int hr = theCalendar.get(Calendar.HOUR_OF_DAY); int min = theCalendar.get(Calendar.MINUTE); float sec = theCalendar.get(Calendar.SECOND) + (theCalendar.get(Calendar.MILLISECOND) / 1000.0F); setDateSecondPrecision(yr, mnth, dy, hr, min, sec); // 3410095: care for integer overflow and timezones not at the full hour, e.g. India int timeZoneOffset = theCalendar.get(Calendar.ZONE_OFFSET) + theCalendar.get(Calendar.DST_OFFSET); int hourOffset= timeZoneOffset / (1000 * 60 * 60); int minuteOffset = (timeZoneOffset / (1000 * 60)) % 60; int zoneOffset = hourOffset * 100 + minuteOffset; setOffset(zoneOffset); }
/** * Convenience setter which sets the value using a {@link Calendar} object. * Passing in <code>null</code> clears any existing value. * * Note: Sets fields using precision up to the millisecond, including timezone offset * * @param theCalendar The calendar object from which to retrieve values * @since 1.1 */ public void setValue(Calendar theCalendar) throws DataTypeException { if (theCalendar == null) { setValue((String)null); return; } int yr = theCalendar.get(Calendar.YEAR); int mnth = theCalendar.get(Calendar.MONTH) + 1; int dy = theCalendar.get(Calendar.DATE); int hr = theCalendar.get(Calendar.HOUR_OF_DAY); int min = theCalendar.get(Calendar.MINUTE); float sec = theCalendar.get(Calendar.SECOND) + (theCalendar.get(Calendar.MILLISECOND) / 1000.0F); setDateSecondPrecision(yr, mnth, dy, hr, min, sec); // 3410095: care for integer overflow and timezones not at the full hour, e.g. India int timeZoneOffset = theCalendar.get(Calendar.ZONE_OFFSET) + theCalendar.get(Calendar.DST_OFFSET); int hourOffset= timeZoneOffset / (1000 * 60 * 60); int minuteOffset = (timeZoneOffset / (1000 * 60)) % 60; int zoneOffset = hourOffset * 100 + minuteOffset; setOffset(zoneOffset); }
ts.setOffset(calOffset); val = ts.getValue();
ts.setOffset(calOffset); val = ts.getValue();