jdk/src/share/classes/sun/util/calendar/CalendarDate.java
author sherman
Tue, 30 Aug 2011 11:53:11 -0700
changeset 10419 12c063b39232
parent 5506 202f599c92aa
child 14342 8435a30053c1
permissions -rw-r--r--
7084245: Update usages of InternalError to use exception chaining Summary: to use new InternalError constructor with cause chainning Reviewed-by: alanb, ksrini, xuelei, neugens Contributed-by: sebastian.sickelmann@gmx.de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.util.calendar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.lang.Cloneable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.TimeZone;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * The <code>CalendarDate</code> class represents a specific instant
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * in time by calendar date and time fields that are multiple cycles
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * in different time unites. The semantics of each calendar field is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * given by a concrete calendar system rather than this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <code>CalendarDate</code> class that holds calendar field values
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * without interpreting them. Therefore, this class can be used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * represent an amount of time, such as 2 years and 3 months.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p>A <code>CalendarDate</code> instance can be created by calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * the <code>newCalendarDate</code> or <code>getCalendarDate</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * methods in <code>CalendarSystem</code>. A
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <code>CalendarSystem</code> instance is obtained by calling one of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * the factory methods in <code>CalendarSystem</code>. Manipulations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * of calendar dates must be handled by the calendar system by which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * <code>CalendarDate</code> instances have been created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <p>Some calendar fields can be modified through method calls. Any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * modification of a calendar field brings the state of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <code>CalendarDate</code> to <I>not normalized</I>. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * normalization must be performed to make all the calendar fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * consistent with a calendar system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <p>The <code>protected</code> methods are intended to be used for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * implementing a concrete calendar system, not for general use as an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * API.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * @see CalendarSystem
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @author Masayoshi Okutsu
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
public abstract class CalendarDate implements Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public static final int FIELD_UNDEFINED = Integer.MIN_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public static final long TIME_UNDEFINED = Long.MIN_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private Era era;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private int year;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private int month;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private int dayOfMonth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private int dayOfWeek = FIELD_UNDEFINED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private boolean leapYear;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private int hours;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private int minutes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private int seconds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private int millis;         // fractional part of the second
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    private long fraction;      // time of day value in millisecond
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private boolean normalized;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    private TimeZone zoneinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private int zoneOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    private int daylightSaving;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    private boolean forceStandardTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    private Locale locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    protected CalendarDate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        this(TimeZone.getDefault());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    protected CalendarDate(TimeZone zone) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        zoneinfo = zone;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public Era getEra() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        return era;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * Sets the era of the date to the specified era. The default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * implementation of this method accepts any Era value, including
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @exception NullPointerException if the calendar system for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * <code>CalendarDate</code> requires eras and the specified era
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @exception IllegalArgumentException if the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * <code>era</code> is unknown to the calendar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * system for this <code>CalendarDate</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    public CalendarDate setEra(Era era) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        if (this.era == era) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        this.era = era;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public int getYear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        return year;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public CalendarDate setYear(int year) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        if (this.year != year) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            this.year = year;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public CalendarDate addYear(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        if (n != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            year += n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Returns whether the year represented by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * <code>CalendarDate</code> is a leap year. If leap years are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * not applicable to the calendar system, this method always
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * returns <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * <p>If this <code>CalendarDate</code> hasn't been normalized,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * <code>false</code> is returned. The normalization must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * performed to retrieve the correct leap year information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @return <code>true</code> if this <code>CalendarDate</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * normalized and the year of this <code>CalendarDate</code> is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * leap year, or <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @see BaseCalendar#isGregorianLeapYear
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    public boolean isLeapYear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        return leapYear;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    void setLeapYear(boolean leapYear) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        this.leapYear = leapYear;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public int getMonth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        return month;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    public CalendarDate setMonth(int month) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        if (this.month != month) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            this.month = month;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public CalendarDate addMonth(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        if (n != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            month += n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public int getDayOfMonth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        return dayOfMonth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public CalendarDate setDayOfMonth(int date) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        if (dayOfMonth != date) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            dayOfMonth = date;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public CalendarDate addDayOfMonth(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if (n != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            dayOfMonth += n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * Returns the day of week value. If this CalendarDate is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * normalized, {@link #FIELD_UNDEFINED} is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @return day of week or {@link #FIELD_UNDEFINED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public int getDayOfWeek() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        if (!isNormalized()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            dayOfWeek = FIELD_UNDEFINED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        return dayOfWeek;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    public int getHours() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return hours;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public CalendarDate setHours(int hours) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        if (this.hours != hours) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            this.hours = hours;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public CalendarDate addHours(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        if (n != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            hours += n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    public int getMinutes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        return minutes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    public CalendarDate setMinutes(int minutes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        if (this.minutes != minutes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            this.minutes = minutes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public CalendarDate addMinutes(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        if (n != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            minutes += n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    public int getSeconds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        return seconds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public CalendarDate setSeconds(int seconds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        if (this.seconds != seconds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            this.seconds = seconds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    public CalendarDate addSeconds(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        if (n != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            seconds += n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    public int getMillis() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        return millis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    public CalendarDate setMillis(int millis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        if (this.millis != millis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            this.millis = millis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public CalendarDate addMillis(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        if (n != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            millis += n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            normalized = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    public long getTimeOfDay() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        if (!isNormalized()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            return fraction = TIME_UNDEFINED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        return fraction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    public CalendarDate setDate(int year, int month, int dayOfMonth) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        setYear(year);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        setMonth(month);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        setDayOfMonth(dayOfMonth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public CalendarDate addDate(int year, int month, int dayOfMonth) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        addYear(year);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        addMonth(month);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        addDayOfMonth(dayOfMonth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    public CalendarDate setTimeOfDay(int hours, int minutes, int seconds, int millis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        setHours(hours);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        setMinutes(minutes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        setSeconds(seconds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        setMillis(millis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public CalendarDate addTimeOfDay(int hours, int minutes, int seconds, int millis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        addHours(hours);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        addMinutes(minutes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        addSeconds(seconds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        addMillis(millis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    protected void setTimeOfDay(long fraction) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        this.fraction = fraction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    public boolean isNormalized() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        return normalized;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    public boolean isStandardTime() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        return forceStandardTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    public void setStandardTime(boolean standardTime) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        forceStandardTime = standardTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    public boolean isDaylightTime() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        if (isStandardTime()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        return daylightSaving != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    protected void setLocale(Locale loc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        locale = loc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    public TimeZone getZone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        return zoneinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    public CalendarDate setZone(TimeZone zoneinfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        this.zoneinfo = zoneinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * Returns whether the specified date is the same date of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * <code>CalendarDate</code>. The time of the day fields are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * ignored for the comparison.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    public boolean isSameDate(CalendarDate date) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        return getDayOfWeek() == date.getDayOfWeek()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            && getMonth() == date.getMonth()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            && getYear() == date.getYear()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            && getEra() == date.getEra();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        if (!(obj instanceof CalendarDate)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        CalendarDate that = (CalendarDate) obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        if (isNormalized() != that.isNormalized()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        boolean hasZone = zoneinfo != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        boolean thatHasZone = that.zoneinfo != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        if (hasZone != thatHasZone) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        if (hasZone && !zoneinfo.equals(that.zoneinfo)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        return (getEra() == that.getEra()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                && year == that.year
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                && month == that.month
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                && dayOfMonth == that.dayOfMonth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                && hours == that.hours
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                && minutes == that.minutes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                && seconds == that.seconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                && millis == that.millis
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                && zoneOffset == that.zoneOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        // a pseudo (local standard) time stamp value in milliseconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        // from the Epoch, assuming Gregorian calendar fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        long hash = ((((((long)year - 1970) * 12) + (month - 1)) * 30) + dayOfMonth) * 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        hash = ((((((hash + hours) * 60) + minutes) * 60) + seconds) * 1000) + millis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        hash -= zoneOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        int normalized = isNormalized() ? 1 : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        int era = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        Era e = getEra();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        if (e != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            era = e.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        int zone = zoneinfo != null ? zoneinfo.hashCode() : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        return (int) hash * (int)(hash >> 32) ^ era ^ normalized ^ zone;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * Returns a copy of this <code>CalendarDate</code>. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * <code>TimeZone</code> object, if any, is not cloned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @return a copy of this <code>CalendarDate</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            return super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        } catch (CloneNotSupportedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            // this shouldn't happen
10419
12c063b39232 7084245: Update usages of InternalError to use exception chaining
sherman
parents: 5506
diff changeset
   438
            throw new InternalError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * Converts calendar date values to a <code>String</code> in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * following format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     *     yyyy-MM-dd'T'HH:mm:ss.SSSz
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * @see java.text.SimpleDateFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        StringBuilder sb = new StringBuilder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        CalendarUtils.sprintf0d(sb, year, 4).append('-');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        CalendarUtils.sprintf0d(sb, month, 2).append('-');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        CalendarUtils.sprintf0d(sb, dayOfMonth, 2).append('T');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        CalendarUtils.sprintf0d(sb, hours, 2).append(':');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        CalendarUtils.sprintf0d(sb, minutes, 2).append(':');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        CalendarUtils.sprintf0d(sb, seconds, 2).append('.');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        CalendarUtils.sprintf0d(sb, millis, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        if (zoneOffset == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            sb.append('Z');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        } else if (zoneOffset != FIELD_UNDEFINED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            int offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            char sign;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            if (zoneOffset > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                offset = zoneOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                sign = '+';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                offset = -zoneOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                sign = '-';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            offset /= 60000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            sb.append(sign);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            CalendarUtils.sprintf0d(sb, offset / 60, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            CalendarUtils.sprintf0d(sb, offset % 60, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            sb.append(" local time");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        return sb.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    protected void setDayOfWeek(int dayOfWeek) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        this.dayOfWeek = dayOfWeek;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    protected void setNormalized(boolean normalized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        this.normalized = normalized;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    public int getZoneOffset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        return zoneOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    protected void setZoneOffset(int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        zoneOffset = offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    public int getDaylightSaving() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        return daylightSaving;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    protected void setDaylightSaving(int daylightSaving) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        this.daylightSaving = daylightSaving;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
}