protected void appendTimeZoneString(StringBuffer result) { if (!isUTC()) { return; } // By default we append a 'Z' to indicate UTC if (this.getZoneHour() == 0 && this.getZoneMinute() == 0) { result.append('Z'); return; } if (isZoneNegative()) { result.append('-'); } else { result.append('+'); } if ((this.getZoneHour() / 10) == 0) { result.append(0); } result.append(this.getZoneHour()); result.append(':'); if ((this.getZoneMinute() / 10) == 0) { result.append(0); } result.append(this.getZoneMinute()); }
protected void appendTimeZoneString(StringBuffer result) { if (!isUTC()) { return; } // By default we append a 'Z' to indicate UTC if (this.getZoneHour() == 0 && this.getZoneMinute() == 0) { result.append('Z'); return; } if (isZoneNegative()) { result.append('-'); } else { result.append('+'); } if ((this.getZoneHour()/10) == 0) { result.append(0); } result.append(this.getZoneHour()); result.append(':'); if ((this.getZoneMinute()/10) == 0) { result.append(0); } result.append(this.getZoneMinute()); }
/** * Sets the time zone in the provided DateFormat. * * @param df */ protected void setDateFormatTimeZone(DateFormat df) { // If no time zone, nothing to do if (!isUTC()) { return; } int offset = (this.getZoneMinute() + this.getZoneHour() * 60) * 60 * 1000; offset = isZoneNegative() ? -offset : offset; SimpleTimeZone timeZone = new SimpleTimeZone(0, "UTC"); timeZone.setRawOffset(offset); timeZone.setID(TimeZone.getAvailableIDs(offset)[0]); df.setTimeZone(timeZone); }
/** * Sets the time zone in the provided DateFormat. * @param df */ protected void setDateFormatTimeZone(DateFormat df) { // If no time zone, nothing to do if (! isUTC()) { return; } int offset = (this.getZoneMinute() + this.getZoneHour() * 60) * 60 * 1000; offset = isZoneNegative() ? -offset : offset; SimpleTimeZone timeZone = new SimpleTimeZone(0,"UTC"); timeZone.setRawOffset(offset); timeZone.setID(TimeZone.getAvailableIDs(offset)[0]); df.setTimeZone(timeZone); }
/** * Sets the time zone in the provided Calendar. * @param calendar */ protected void setDateFormatTimeZone(Calendar calendar) { // If no time zone, nothing to do if (! isUTC()) { return; } int offset = (this.getZoneMinute() + this.getZoneHour() * 60) * 60 * 1000; offset = isZoneNegative() ? -offset : offset; SimpleTimeZone timeZone = new SimpleTimeZone(0,"UTC"); timeZone.setRawOffset(offset); String[] availableIDs = TimeZone.getAvailableIDs(offset); if (availableIDs != null && availableIDs.length > 0) { timeZone.setID(availableIDs[0]); } calendar.setTimeZone(timeZone); }
/** * Sets the time zone in the provided Calendar. * * @param calendar */ protected void setDateFormatTimeZone(Calendar calendar) { // If no time zone, nothing to do if (!isUTC()) { return; } int offset = (this.getZoneMinute() + this.getZoneHour() * 60) * 60 * 1000; offset = isZoneNegative() ? -offset : offset; SimpleTimeZone timeZone = new SimpleTimeZone(0, "UTC"); timeZone.setRawOffset(offset); String[] availableIDs = TimeZone.getAvailableIDs(offset); if (availableIDs != null && availableIDs.length > 0) { timeZone.setID(availableIDs[0]); } calendar.setTimeZone(timeZone); }
public DateTimeBase clone(DateTimeBase dateTime) throws CloneNotSupportedException { DateTimeBase newDateTime = (DateTimeBase) super.clone(); // newDateTime = (DateTimeBase) dateTime.getClass().newInstance(); newDateTime.setValues(dateTime.getValues()); if (dateTime.hasIsNegative() && dateTime.isNegative()) { newDateTime.setNegative(); } if (dateTime.isUTC()) { newDateTime.setUTC(); newDateTime.setZone(dateTime.getZoneHour(), dateTime.getZoneMinute()); newDateTime.setZoneNegative(dateTime.isZoneNegative()); } return newDateTime; }
public DateTimeBase clone(DateTimeBase dateTime) throws CloneNotSupportedException { DateTimeBase newDateTime = (DateTimeBase) super.clone(); // newDateTime = (DateTimeBase) dateTime.getClass().newInstance(); newDateTime.setValues(dateTime.getValues()); if (dateTime.hasIsNegative() && dateTime.isNegative()) { newDateTime.setNegative(); } if (dateTime.isUTC()) { newDateTime.setUTC(); newDateTime.setZone(dateTime.getZoneHour(), dateTime.getZoneMinute()); newDateTime.setZoneNegative(dateTime.isZoneNegative()); } return newDateTime; }