jdk/src/share/classes/java/time/chrono/HijrahEra.java
author sherman
Wed, 15 May 2013 07:48:57 -0700
changeset 17474 8c100beabcc0
parent 16852 60207b2b4b42
child 19841 15c8e97d6a14
permissions -rw-r--r--
8013730: JSR 310 DateTime API Updates III Summary: Integration of JSR310 Date/Time API update III Reviewed-by: naoto Contributed-by: scolebourne@joda.org, roger.riggs@oracle.com, masayoshi.okutsu@oracle.com, patrick.zhang@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     1
/*
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     2
 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     4
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    10
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    15
 * accompanied this code).
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    16
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    20
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    23
 * questions.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    24
 */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    25
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    26
/*
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    27
 * This file is available under and governed by the GNU General Public
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    28
 * License version 2 only, as published by the Free Software Foundation.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    29
 * However, the following notice accompanied the original version of this
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    30
 * file:
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    31
 *
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    32
 * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    33
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    34
 * All rights reserved.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    35
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    36
 * Redistribution and use in source and binary forms, with or without
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    37
 * modification, are permitted provided that the following conditions are met:
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    38
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    39
 *  * Redistributions of source code must retain the above copyright notice,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    40
 *    this list of conditions and the following disclaimer.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    41
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    42
 *  * Redistributions in binary form must reproduce the above copyright notice,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    43
 *    this list of conditions and the following disclaimer in the documentation
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    44
 *    and/or other materials provided with the distribution.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    45
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    46
 *  * Neither the name of JSR-310 nor the names of its contributors
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    47
 *    may be used to endorse or promote products derived from this software
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    48
 *    without specific prior written permission.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    49
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    50
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    51
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    52
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    53
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    54
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    55
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    56
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    57
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    58
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    59
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    60
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    61
 */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    62
package java.time.chrono;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    63
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    64
import static java.time.temporal.ChronoField.ERA;
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    65
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    66
import java.io.DataInput;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    67
import java.io.DataOutput;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    68
import java.io.IOException;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    69
import java.time.DateTimeException;
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    70
import java.time.temporal.ChronoField;
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    71
import java.time.temporal.TemporalField;
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    72
import java.time.temporal.UnsupportedTemporalTypeException;
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    73
import java.time.temporal.ValueRange;
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    74
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    75
/**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    76
 * An era in the Hijrah calendar system.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    77
 * <p>
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    78
 * The Hijrah calendar system has only one era covering the
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    79
 * proleptic years greater than zero.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    80
 * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    81
 * <b>Do not use {@code ordinal()} to obtain the numeric representation of {@code HijrahEra}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    82
 * Use {@code getValue()} instead.</b>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    83
 *
17474
8c100beabcc0 8013730: JSR 310 DateTime API Updates III
sherman
parents: 16852
diff changeset
    84
 * @implSpec
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    85
 * This is an immutable and thread-safe enum.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    86
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    87
 * @since 1.8
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    88
 */
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    89
public enum HijrahEra implements Era {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    90
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    91
    /**
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    92
     * The singleton instance for the current era, 'Anno Hegirae',
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    93
     * which has the numeric value 1.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    94
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    95
    AH;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    96
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    97
    //-----------------------------------------------------------------------
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    98
    /**
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    99
     * Obtains an instance of {@code HijrahEra} from an {@code int} value.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   100
     * <p>
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   101
     * The current era, which is the only accepted value, has the value 1
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   102
     *
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   103
     * @param hijrahEra  the era to represent, only 1 supported
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   104
     * @return the HijrahEra.AH singleton, not null
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   105
     * @throws DateTimeException if the value is invalid
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   106
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   107
    public static HijrahEra of(int hijrahEra) {
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   108
        if (hijrahEra == 1 ) {
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   109
            return AH;
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   110
        } else {
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   111
            throw new DateTimeException("Invalid era: " + hijrahEra);
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   112
        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   113
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   114
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   115
    //-----------------------------------------------------------------------
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   116
    /**
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   117
     * Gets the numeric era {@code int} value.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   118
     * <p>
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   119
     * The era AH has the value 1.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   120
     *
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   121
     * @return the era value, 1 (AH)
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   122
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   123
    @Override
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   124
    public int getValue() {
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   125
        return 1;
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   126
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   127
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   128
    //-----------------------------------------------------------------------
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   129
    /**
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   130
     * Gets the range of valid values for the specified field.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   131
     * <p>
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   132
     * The range object expresses the minimum and maximum valid values for a field.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   133
     * This era is used to enhance the accuracy of the returned range.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   134
     * If it is not possible to return the range, because the field is not supported
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   135
     * or for some other reason, an exception is thrown.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   136
     * <p>
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   137
     * If the field is a {@link ChronoField} then the query is implemented here.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   138
     * The {@code ERA} field returns the range.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   139
     * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   140
     * <p>
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   141
     * If the field is not a {@code ChronoField}, then the result of this method
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   142
     * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)}
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   143
     * passing {@code this} as the argument.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   144
     * Whether the range can be obtained is determined by the field.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   145
     * <p>
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   146
     * The {@code ERA} field returns a range for the one valid Hijrah era.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   147
     *
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   148
     * @param field  the field to query the range for, not null
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   149
     * @return the range of valid values for the field, not null
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   150
     * @throws DateTimeException if the range for the field cannot be obtained
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   151
     * @throws UnsupportedTemporalTypeException if the unit is not supported
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   152
     */
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   153
    @Override  // override as super would return range from 0 to 1
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   154
    public ValueRange range(TemporalField field) {
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   155
        if (field == ERA) {
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   156
            return ValueRange.of(1, 1);
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   157
        }
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   158
        return Era.super.range(field);
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   159
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   160
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   161
    //-----------------------------------------------------------------------
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   162
    private Object writeReplace() {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   163
        return new Ser(Ser.HIJRAH_ERA_TYPE, this);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   164
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   165
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   166
    void writeExternal(DataOutput out) throws IOException {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   167
        out.writeByte(this.getValue());
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   168
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   169
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   170
    static HijrahEra readExternal(DataInput in) throws IOException {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   171
        byte eraValue = in.readByte();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   172
        return HijrahEra.of(eraValue);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   173
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   174
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   175
}