/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The <code>CalendarDate</code> class represents a specific instant
* in time by calendar date and time fields that are multiple cycles
* in different time unites. The semantics of each calendar field is
* given by a concrete calendar system rather than this
* <code>CalendarDate</code> class that holds calendar field values
* without interpreting them. Therefore, this class can be used to
* represent an amount of time, such as 2 years and 3 months.
*
* <p>A <code>CalendarDate</code> instance can be created by calling
* the <code>newCalendarDate</code> or <code>getCalendarDate</code>
* methods in <code>CalendarSystem</code>. A
* <code>CalendarSystem</code> instance is obtained by calling one of
* the factory methods in <code>CalendarSystem</code>. Manipulations
* of calendar dates must be handled by the calendar system by which
* <code>CalendarDate</code> instances have been created.
*
* <p>Some calendar fields can be modified through method calls. Any
* modification of a calendar field brings the state of a
* <code>CalendarDate</code> to <I>not normalized</I>. The
* normalization must be performed to make all the calendar fields
* consistent with a calendar system.
*
* <p>The <code>protected</code> methods are intended to be used for
* implementing a concrete calendar system, not for general use as an
* API.
*
* @see CalendarSystem
* @author Masayoshi Okutsu
* @since 1.5
*/
private int year;
private int month;
private int dayOfMonth;
private boolean leapYear;
private int hours;
private int minutes;
private int seconds;
private boolean normalized;
private int zoneOffset;
private int daylightSaving;
private boolean forceStandardTime;
protected CalendarDate() {
this(TimeZone.getDefault());
}
}
return era;
}
/**
* Sets the era of the date to the specified era. The default
* implementation of this method accepts any Era value, including
* <code>null</code>.
*
* @exception NullPointerException if the calendar system for this
* <code>CalendarDate</code> requires eras and the specified era
* is null.
* @exception IllegalArgumentException if the specified
* <code>era</code> is unknown to the calendar
* system for this <code>CalendarDate</code>.
*/
return this;
}
normalized = false;
return this;
}
public int getYear() {
return year;
}
normalized = false;
}
return this;
}
if (n != 0) {
year += n;
normalized = false;
}
return this;
}
/**
* Returns whether the year represented by this
* <code>CalendarDate</code> is a leap year. If leap years are
* not applicable to the calendar system, this method always
* returns <code>false</code>.
*
* <p>If this <code>CalendarDate</code> hasn't been normalized,
* <code>false</code> is returned. The normalization must be
* performed to retrieve the correct leap year information.
*
* @return <code>true</code> if this <code>CalendarDate</code> is
* normalized and the year of this <code>CalendarDate</code> is a
* leap year, or <code>false</code> otherwise.
* @see BaseCalendar#isGregorianLeapYear
*/
public boolean isLeapYear() {
return leapYear;
}
}
public int getMonth() {
return month;
}
normalized = false;
}
return this;
}
if (n != 0) {
month += n;
normalized = false;
}
return this;
}
public int getDayOfMonth() {
return dayOfMonth;
}
if (dayOfMonth != date) {
dayOfMonth = date;
normalized = false;
}
return this;
}
if (n != 0) {
dayOfMonth += n;
normalized = false;
}
return this;
}
/**
* Returns the day of week value. If this CalendarDate is not
* normalized, {@link #FIELD_UNDEFINED} is returned.
*
* @return day of week or {@link #FIELD_UNDEFINED}
*/
public int getDayOfWeek() {
if (!isNormalized()) {
}
return dayOfWeek;
}
public int getHours() {
return hours;
}
normalized = false;
}
return this;
}
if (n != 0) {
hours += n;
normalized = false;
}
return this;
}
public int getMinutes() {
return minutes;
}
normalized = false;
}
return this;
}
if (n != 0) {
minutes += n;
normalized = false;
}
return this;
}
public int getSeconds() {
return seconds;
}
normalized = false;
}
return this;
}
if (n != 0) {
seconds += n;
normalized = false;
}
return this;
}
public int getMillis() {
return millis;
}
normalized = false;
}
return this;
}
if (n != 0) {
millis += n;
normalized = false;
}
return this;
}
public long getTimeOfDay() {
if (!isNormalized()) {
return fraction = TIME_UNDEFINED;
}
return fraction;
}
return this;
}
return this;
}
return this;
}
return this;
}
}
public boolean isNormalized() {
return normalized;
}
public boolean isStandardTime() {
return forceStandardTime;
}
}
public boolean isDaylightTime() {
if (isStandardTime()) {
return false;
}
return daylightSaving != 0;
}
}
return zoneinfo;
}
return this;
}
/**
* Returns whether the specified date is the same date of this
* <code>CalendarDate</code>. The time of the day fields are
* ignored for the comparison.
*/
}
if (!(obj instanceof CalendarDate)) {
return false;
}
return false;
}
if (hasZone != thatHasZone) {
return false;
}
return false;
}
}
public int hashCode() {
// a pseudo (local standard) time stamp value in milliseconds
// from the Epoch, assuming Gregorian calendar fields.
hash -= zoneOffset;
int era = 0;
if (e != null) {
}
}
/**
* Returns a copy of this <code>CalendarDate</code>. The
* <code>TimeZone</code> object, if any, is not cloned.
*
* @return a copy of this <code>CalendarDate</code>
*/
try {
return super.clone();
} catch (CloneNotSupportedException e) {
// this shouldn't happen
throw new InternalError();
}
}
/**
* Converts calendar date values to a <code>String</code> in the
* following format.
* <pre>
* yyyy-MM-dd'T'HH:mm:ss.SSSz
* </pre>
*
* @see java.text.SimpleDateFormat
*/
if (zoneOffset == 0) {
} else if (zoneOffset != FIELD_UNDEFINED) {
int offset;
char sign;
if (zoneOffset > 0) {
offset = zoneOffset;
sign = '+';
} else {
offset = -zoneOffset;
sign = '-';
}
offset /= 60000;
} else {
}
}
}
this.normalized = normalized;
}
public int getZoneOffset() {
return zoneOffset;
}
zoneOffset = offset;
}
public int getDaylightSaving() {
return daylightSaving;
}
this.daylightSaving = daylightSaving;
}
}