jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 24256 jdk/src/share/classes/java/time/chrono/ChronoZonedDateTime.java@da9a41004459
child 44600 2027ac642982
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@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
/*
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    27
 * This file is available under and governed by the GNU General Public
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    28
 * License version 2 only, as published by the Free Software Foundation.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    29
 * However, the following notice accompanied the original version of this
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    30
 * file:
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    31
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    32
 * Copyright (c) 2007-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
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    64
import static java.time.temporal.ChronoField.INSTANT_SECONDS;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    65
import static java.time.temporal.ChronoField.OFFSET_SECONDS;
19030
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
    66
import static java.time.temporal.ChronoUnit.FOREVER;
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    67
import static java.time.temporal.ChronoUnit.NANOS;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    68
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    69
import java.time.DateTimeException;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    70
import java.time.Instant;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    71
import java.time.LocalTime;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    72
import java.time.ZoneId;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    73
import java.time.ZoneOffset;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    74
import java.time.ZonedDateTime;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    75
import java.time.format.DateTimeFormatter;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    76
import java.time.temporal.ChronoField;
19030
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
    77
import java.time.temporal.ChronoUnit;
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    78
import java.time.temporal.Temporal;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    79
import java.time.temporal.TemporalAccessor;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    80
import java.time.temporal.TemporalAdjuster;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    81
import java.time.temporal.TemporalAmount;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    82
import java.time.temporal.TemporalField;
20795
8ec9e5b79828 8025722: TemporalAdjusters and TemporalQueries
rriggs
parents: 20794
diff changeset
    83
import java.time.temporal.TemporalQueries;
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    84
import java.time.temporal.TemporalQuery;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    85
import java.time.temporal.TemporalUnit;
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
    86
import java.time.temporal.UnsupportedTemporalTypeException;
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    87
import java.time.temporal.ValueRange;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    88
import java.util.Comparator;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    89
import java.util.Objects;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    90
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    91
/**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    92
 * A date-time with a time-zone in an arbitrary chronology,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    93
 * intended for advanced globalization use cases.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    94
 * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    95
 * <b>Most applications should declare method signatures, fields and variables
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    96
 * as {@link ZonedDateTime}, not this interface.</b>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    97
 * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    98
 * A {@code ChronoZonedDateTime} is the abstract representation of an offset date-time
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    99
 * where the {@code Chronology chronology}, or calendar system, is pluggable.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   100
 * The date-time is defined in terms of fields expressed by {@link TemporalField},
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   101
 * where most common implementations are defined in {@link ChronoField}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   102
 * The chronology defines how the calendar system operates and the meaning of
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   103
 * the standard fields.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   104
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   105
 * <h3>When to use this interface</h3>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   106
 * The design of the API encourages the use of {@code ZonedDateTime} rather than this
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   107
 * interface, even in the case where the application needs to deal with multiple
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   108
 * calendar systems. The rationale for this is explored in detail in {@link ChronoLocalDate}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   109
 * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   110
 * Ensure that the discussion in {@code ChronoLocalDate} has been read and understood
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   111
 * before using this interface.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   112
 *
17474
8c100beabcc0 8013730: JSR 310 DateTime API Updates III
sherman
parents: 16852
diff changeset
   113
 * @implSpec
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   114
 * This interface must be implemented with care to ensure other classes operate correctly.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   115
 * All implementations that can be instantiated must be final, immutable and thread-safe.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   116
 * Subclasses should be Serializable wherever possible.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   117
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   118
 * @param <D> the concrete type for the date of this date-time
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   119
 * @since 1.8
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   120
 */
19030
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   121
public interface ChronoZonedDateTime<D extends ChronoLocalDate>
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   122
        extends Temporal, Comparable<ChronoZonedDateTime<?>> {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   123
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   124
    /**
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   125
     * Gets a comparator that compares {@code ChronoZonedDateTime} in
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   126
     * time-line order ignoring the chronology.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   127
     * <p>
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   128
     * This comparator differs from the comparison in {@link #compareTo} in that it
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   129
     * only compares the underlying instant and not the chronology.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   130
     * This allows dates in different calendar systems to be compared based
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   131
     * on the position of the date-time on the instant time-line.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   132
     * The underlying comparison is equivalent to comparing the epoch-second and nano-of-second.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   133
     *
17474
8c100beabcc0 8013730: JSR 310 DateTime API Updates III
sherman
parents: 16852
diff changeset
   134
     * @return a comparator that compares in time-line order ignoring the chronology
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   135
     * @see #isAfter
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   136
     * @see #isBefore
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   137
     * @see #isEqual
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   138
     */
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   139
    static Comparator<ChronoZonedDateTime<?>> timeLineOrder() {
20794
ec823009c5f7 8025719: Change Chronology to an interface
scolebourne
parents: 20522
diff changeset
   140
        return AbstractChronology.INSTANT_ORDER;
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   141
    }
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   142
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   143
    //-----------------------------------------------------------------------
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   144
    /**
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   145
     * Obtains an instance of {@code ChronoZonedDateTime} from a temporal object.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   146
     * <p>
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   147
     * This creates a zoned date-time based on the specified temporal.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   148
     * A {@code TemporalAccessor} represents an arbitrary set of date and time information,
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   149
     * which this factory converts to an instance of {@code ChronoZonedDateTime}.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   150
     * <p>
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   151
     * The conversion extracts and combines the chronology, date, time and zone
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   152
     * from the temporal object. The behavior is equivalent to using
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   153
     * {@link Chronology#zonedDateTime(TemporalAccessor)} with the extracted chronology.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   154
     * Implementations are permitted to perform optimizations such as accessing
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   155
     * those fields that are equivalent to the relevant objects.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   156
     * <p>
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   157
     * This method matches the signature of the functional interface {@link TemporalQuery}
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   158
     * allowing it to be used as a query via method reference, {@code ChronoZonedDateTime::from}.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   159
     *
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20795
diff changeset
   160
     * @param temporal  the temporal object to convert, not null
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   161
     * @return the date-time, not null
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   162
     * @throws DateTimeException if unable to convert to a {@code ChronoZonedDateTime}
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   163
     * @see Chronology#zonedDateTime(TemporalAccessor)
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   164
     */
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   165
    static ChronoZonedDateTime<?> from(TemporalAccessor temporal) {
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   166
        if (temporal instanceof ChronoZonedDateTime) {
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   167
            return (ChronoZonedDateTime<?>) temporal;
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   168
        }
20520
0952771e3e25 8024835: Change until() to accept any compatible temporal
rriggs
parents: 19030
diff changeset
   169
        Objects.requireNonNull(temporal, "temporal");
20795
8ec9e5b79828 8025722: TemporalAdjusters and TemporalQueries
rriggs
parents: 20794
diff changeset
   170
        Chronology chrono = temporal.query(TemporalQueries.chronology());
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   171
        if (chrono == null) {
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   172
            throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass());
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   173
        }
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   174
        return chrono.zonedDateTime(temporal);
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   175
    }
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   176
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   177
    //-----------------------------------------------------------------------
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   178
    @Override
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   179
    default ValueRange range(TemporalField field) {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   180
        if (field instanceof ChronoField) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   181
            if (field == INSTANT_SECONDS || field == OFFSET_SECONDS) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   182
                return field.range();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   183
            }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   184
            return toLocalDateTime().range(field);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   185
        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   186
        return field.rangeRefinedBy(this);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   187
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   188
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   189
    @Override
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   190
    default int get(TemporalField field) {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   191
        if (field instanceof ChronoField) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   192
            switch ((ChronoField) field) {
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   193
                case INSTANT_SECONDS:
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   194
                    throw new UnsupportedTemporalTypeException("Invalid field 'InstantSeconds' for get() method, use getLong() instead");
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   195
                case OFFSET_SECONDS:
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   196
                    return getOffset().getTotalSeconds();
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   197
            }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   198
            return toLocalDateTime().get(field);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   199
        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   200
        return Temporal.super.get(field);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   201
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   202
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   203
    @Override
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   204
    default long getLong(TemporalField field) {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   205
        if (field instanceof ChronoField) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   206
            switch ((ChronoField) field) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   207
                case INSTANT_SECONDS: return toEpochSecond();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   208
                case OFFSET_SECONDS: return getOffset().getTotalSeconds();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   209
            }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   210
            return toLocalDateTime().getLong(field);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   211
        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   212
        return field.getFrom(this);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   213
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   214
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   215
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   216
     * Gets the local date part of this date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   217
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   218
     * This returns a local date with the same year, month and day
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   219
     * as this date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   220
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   221
     * @return the date part of this date-time, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   222
     */
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   223
    default D toLocalDate() {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   224
        return toLocalDateTime().toLocalDate();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   225
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   226
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   227
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   228
     * Gets the local time part of this date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   229
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   230
     * This returns a local time with the same hour, minute, second and
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   231
     * nanosecond as this date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   232
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   233
     * @return the time part of this date-time, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   234
     */
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   235
    default LocalTime toLocalTime() {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   236
        return toLocalDateTime().toLocalTime();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   237
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   238
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   239
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   240
     * Gets the local date-time part of this date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   241
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   242
     * This returns a local date with the same year, month and day
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   243
     * as this date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   244
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   245
     * @return the local date-time part of this date-time, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   246
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   247
    ChronoLocalDateTime<D> toLocalDateTime();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   248
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   249
    /**
20522
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   250
     * Gets the chronology of this date-time.
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   251
     * <p>
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   252
     * The {@code Chronology} represents the calendar system in use.
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   253
     * The era and other fields in {@link ChronoField} are defined by the chronology.
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   254
     *
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   255
     * @return the chronology, not null
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   256
     */
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   257
    default Chronology getChronology() {
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   258
        return toLocalDate().getChronology();
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   259
    }
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   260
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   261
    /**
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   262
     * Gets the zone offset, such as '+01:00'.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   263
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   264
     * This is the offset of the local date-time from UTC/Greenwich.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   265
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   266
     * @return the zone offset, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   267
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   268
    ZoneOffset getOffset();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   269
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   270
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   271
     * Gets the zone ID, such as 'Europe/Paris'.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   272
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   273
     * This returns the stored time-zone id used to determine the time-zone rules.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   274
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   275
     * @return the zone ID, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   276
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   277
    ZoneId getZone();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   278
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   279
    //-----------------------------------------------------------------------
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   280
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   281
     * Returns a copy of this date-time changing the zone offset to the
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   282
     * earlier of the two valid offsets at a local time-line overlap.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   283
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   284
     * This method only has any effect when the local time-line overlaps, such as
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   285
     * at an autumn daylight savings cutover. In this scenario, there are two
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   286
     * valid offsets for the local date-time. Calling this method will return
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   287
     * a zoned date-time with the earlier of the two selected.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   288
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   289
     * If this method is called when it is not an overlap, {@code this}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   290
     * is returned.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   291
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   292
     * This instance is immutable and unaffected by this method call.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   293
     *
24256
da9a41004459 8034906: Fix typos, errors and Javadoc differences in java.time
scolebourne
parents: 21278
diff changeset
   294
     * @return a {@code ChronoZonedDateTime} based on this date-time with the earlier offset, not null
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   295
     * @throws DateTimeException if no rules can be found for the zone
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   296
     * @throws DateTimeException if no rules are valid for this date-time
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   297
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   298
    ChronoZonedDateTime<D> withEarlierOffsetAtOverlap();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   299
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   300
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   301
     * Returns a copy of this date-time changing the zone offset to the
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   302
     * later of the two valid offsets at a local time-line overlap.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   303
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   304
     * This method only has any effect when the local time-line overlaps, such as
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   305
     * at an autumn daylight savings cutover. In this scenario, there are two
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   306
     * valid offsets for the local date-time. Calling this method will return
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   307
     * a zoned date-time with the later of the two selected.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   308
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   309
     * If this method is called when it is not an overlap, {@code this}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   310
     * is returned.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   311
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   312
     * This instance is immutable and unaffected by this method call.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   313
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   314
     * @return a {@code ChronoZonedDateTime} based on this date-time with the later offset, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   315
     * @throws DateTimeException if no rules can be found for the zone
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   316
     * @throws DateTimeException if no rules are valid for this date-time
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   317
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   318
    ChronoZonedDateTime<D> withLaterOffsetAtOverlap();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   319
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   320
    /**
24256
da9a41004459 8034906: Fix typos, errors and Javadoc differences in java.time
scolebourne
parents: 21278
diff changeset
   321
     * Returns a copy of this date-time with a different time-zone,
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   322
     * retaining the local date-time if possible.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   323
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   324
     * This method changes the time-zone and retains the local date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   325
     * The local date-time is only changed if it is invalid for the new zone.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   326
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   327
     * To change the zone and adjust the local date-time,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   328
     * use {@link #withZoneSameInstant(ZoneId)}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   329
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   330
     * This instance is immutable and unaffected by this method call.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   331
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   332
     * @param zone  the time-zone to change to, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   333
     * @return a {@code ChronoZonedDateTime} based on this date-time with the requested zone, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   334
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   335
    ChronoZonedDateTime<D> withZoneSameLocal(ZoneId zone);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   336
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   337
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   338
     * Returns a copy of this date-time with a different time-zone,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   339
     * retaining the instant.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   340
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   341
     * This method changes the time-zone and retains the instant.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   342
     * This normally results in a change to the local date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   343
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   344
     * This method is based on retaining the same instant, thus gaps and overlaps
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   345
     * in the local time-line have no effect on the result.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   346
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   347
     * To change the offset while keeping the local time,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   348
     * use {@link #withZoneSameLocal(ZoneId)}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   349
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   350
     * @param zone  the time-zone to change to, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   351
     * @return a {@code ChronoZonedDateTime} based on this date-time with the requested zone, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   352
     * @throws DateTimeException if the result exceeds the supported date range
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   353
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   354
    ChronoZonedDateTime<D> withZoneSameInstant(ZoneId zone);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   355
19030
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   356
    /**
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   357
     * Checks if the specified field is supported.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   358
     * <p>
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   359
     * This checks if the specified field can be queried on this date-time.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   360
     * If false, then calling the {@link #range(TemporalField) range},
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   361
     * {@link #get(TemporalField) get} and {@link #with(TemporalField, long)}
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   362
     * methods will throw an exception.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   363
     * <p>
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   364
     * The set of supported fields is defined by the chronology and normally includes
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   365
     * all {@code ChronoField} fields.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   366
     * <p>
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   367
     * If the field is not a {@code ChronoField}, then the result of this method
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   368
     * is obtained by invoking {@code TemporalField.isSupportedBy(TemporalAccessor)}
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   369
     * passing {@code this} as the argument.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   370
     * Whether the field is supported is determined by the field.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   371
     *
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   372
     * @param field  the field to check, null returns false
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   373
     * @return true if the field can be queried, false if not
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   374
     */
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   375
    @Override
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   376
    boolean isSupported(TemporalField field);
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   377
19030
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   378
    /**
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   379
     * Checks if the specified unit is supported.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   380
     * <p>
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   381
     * This checks if the specified unit can be added to or subtracted from this date-time.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   382
     * If false, then calling the {@link #plus(long, TemporalUnit)} and
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   383
     * {@link #minus(long, TemporalUnit) minus} methods will throw an exception.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   384
     * <p>
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   385
     * The set of supported units is defined by the chronology and normally includes
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   386
     * all {@code ChronoUnit} units except {@code FOREVER}.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   387
     * <p>
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   388
     * If the unit is not a {@code ChronoUnit}, then the result of this method
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   389
     * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)}
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   390
     * passing {@code this} as the argument.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   391
     * Whether the unit is supported is determined by the unit.
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   392
     *
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   393
     * @param unit  the unit to check, null returns false
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   394
     * @return true if the unit can be added/subtracted, false if not
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   395
     */
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   396
    @Override
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   397
    default boolean isSupported(TemporalUnit unit) {
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   398
        if (unit instanceof ChronoUnit) {
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   399
            return unit != FOREVER;
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   400
        }
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   401
        return unit != null && unit.isSupportedBy(this);
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   402
    }
32f129cb6351 8016025: JSR 310 DateTime API Updates IV
sherman
parents: 17474
diff changeset
   403
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   404
    //-----------------------------------------------------------------------
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   405
    // override for covariant return type
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   406
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   407
     * {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   408
     * @throws DateTimeException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   409
     * @throws ArithmeticException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   410
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   411
    @Override
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   412
    default ChronoZonedDateTime<D> with(TemporalAdjuster adjuster) {
20522
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   413
        return ChronoZonedDateTimeImpl.ensureValid(getChronology(), Temporal.super.with(adjuster));
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   414
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   415
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   416
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   417
     * {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   418
     * @throws DateTimeException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   419
     * @throws ArithmeticException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   420
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   421
    @Override
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   422
    ChronoZonedDateTime<D> with(TemporalField field, long newValue);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   423
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   424
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   425
     * {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   426
     * @throws DateTimeException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   427
     * @throws ArithmeticException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   428
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   429
    @Override
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   430
    default ChronoZonedDateTime<D> plus(TemporalAmount amount) {
20522
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   431
        return ChronoZonedDateTimeImpl.ensureValid(getChronology(), Temporal.super.plus(amount));
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   432
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   433
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   434
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   435
     * {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   436
     * @throws DateTimeException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   437
     * @throws ArithmeticException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   438
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   439
    @Override
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   440
    ChronoZonedDateTime<D> plus(long amountToAdd, TemporalUnit unit);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   441
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   442
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   443
     * {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   444
     * @throws DateTimeException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   445
     * @throws ArithmeticException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   446
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   447
    @Override
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   448
    default ChronoZonedDateTime<D> minus(TemporalAmount amount) {
20522
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   449
        return ChronoZonedDateTimeImpl.ensureValid(getChronology(), Temporal.super.minus(amount));
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   450
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   451
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   452
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   453
     * {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   454
     * @throws DateTimeException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   455
     * @throws ArithmeticException {@inheritDoc}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   456
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   457
    @Override
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   458
    default ChronoZonedDateTime<D> minus(long amountToSubtract, TemporalUnit unit) {
20522
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   459
        return ChronoZonedDateTimeImpl.ensureValid(getChronology(), Temporal.super.minus(amountToSubtract, unit));
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   460
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   461
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   462
    //-----------------------------------------------------------------------
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   463
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   464
     * Queries this date-time using the specified query.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   465
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   466
     * This queries this date-time using the specified query strategy object.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   467
     * The {@code TemporalQuery} object defines the logic to be used to
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   468
     * obtain the result. Read the documentation of the query to understand
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   469
     * what the result of this method will be.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   470
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   471
     * The result of this method is obtained by invoking the
24256
da9a41004459 8034906: Fix typos, errors and Javadoc differences in java.time
scolebourne
parents: 21278
diff changeset
   472
     * {@link TemporalQuery#queryFrom(TemporalAccessor)} method on the
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   473
     * specified query passing {@code this} as the argument.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   474
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   475
     * @param <R> the type of the result
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   476
     * @param query  the query to invoke, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   477
     * @return the query result, null may be returned (defined by the query)
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   478
     * @throws DateTimeException if unable to query (defined by the query)
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   479
     * @throws ArithmeticException if numeric overflow occurs (defined by the query)
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   480
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   481
    @SuppressWarnings("unchecked")
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   482
    @Override
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   483
    default <R> R query(TemporalQuery<R> query) {
20795
8ec9e5b79828 8025722: TemporalAdjusters and TemporalQueries
rriggs
parents: 20794
diff changeset
   484
        if (query == TemporalQueries.zone() || query == TemporalQueries.zoneId()) {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   485
            return (R) getZone();
20795
8ec9e5b79828 8025722: TemporalAdjusters and TemporalQueries
rriggs
parents: 20794
diff changeset
   486
        } else if (query == TemporalQueries.offset()) {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   487
            return (R) getOffset();
20795
8ec9e5b79828 8025722: TemporalAdjusters and TemporalQueries
rriggs
parents: 20794
diff changeset
   488
        } else if (query == TemporalQueries.localTime()) {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   489
            return (R) toLocalTime();
20795
8ec9e5b79828 8025722: TemporalAdjusters and TemporalQueries
rriggs
parents: 20794
diff changeset
   490
        } else if (query == TemporalQueries.chronology()) {
20522
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   491
            return (R) getChronology();
20795
8ec9e5b79828 8025722: TemporalAdjusters and TemporalQueries
rriggs
parents: 20794
diff changeset
   492
        } else if (query == TemporalQueries.precision()) {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   493
            return (R) NANOS;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   494
        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   495
        // inline TemporalAccessor.super.query(query) as an optimization
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   496
        // non-JDK classes are not permitted to make this optimization
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   497
        return query.queryFrom(this);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   498
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   499
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   500
    /**
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   501
     * Formats this date-time using the specified formatter.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   502
     * <p>
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   503
     * This date-time will be passed to the formatter to produce a string.
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   504
     * <p>
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   505
     * The default implementation must behave as follows:
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   506
     * <pre>
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   507
     *  return formatter.format(this);
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   508
     * </pre>
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   509
     *
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   510
     * @param formatter  the formatter to use, not null
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   511
     * @return the formatted date-time string, not null
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   512
     * @throws DateTimeException if an error occurs during printing
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   513
     */
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   514
    default String format(DateTimeFormatter formatter) {
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   515
        Objects.requireNonNull(formatter, "formatter");
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   516
        return formatter.format(this);
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   517
    }
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   518
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   519
    //-----------------------------------------------------------------------
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   520
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   521
     * Converts this date-time to an {@code Instant}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   522
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   523
     * This returns an {@code Instant} representing the same point on the
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   524
     * time-line as this date-time. The calculation combines the
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   525
     * {@linkplain #toLocalDateTime() local date-time} and
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   526
     * {@linkplain #getOffset() offset}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   527
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   528
     * @return an {@code Instant} representing the same instant, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   529
     */
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   530
    default Instant toInstant() {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   531
        return Instant.ofEpochSecond(toEpochSecond(), toLocalTime().getNano());
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   532
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   533
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   534
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   535
     * Converts this date-time to the number of seconds from the epoch
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   536
     * of 1970-01-01T00:00:00Z.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   537
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   538
     * This uses the {@linkplain #toLocalDateTime() local date-time} and
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   539
     * {@linkplain #getOffset() offset} to calculate the epoch-second value,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   540
     * which is the number of elapsed seconds from 1970-01-01T00:00:00Z.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   541
     * Instants on the time-line after the epoch are positive, earlier are negative.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   542
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   543
     * @return the number of seconds from the epoch of 1970-01-01T00:00:00Z
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   544
     */
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   545
    default long toEpochSecond() {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   546
        long epochDay = toLocalDate().toEpochDay();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   547
        long secs = epochDay * 86400 + toLocalTime().toSecondOfDay();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   548
        secs -= getOffset().getTotalSeconds();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   549
        return secs;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   550
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   551
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   552
    //-----------------------------------------------------------------------
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   553
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   554
     * Compares this date-time to another date-time, including the chronology.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   555
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   556
     * The comparison is based first on the instant, then on the local date-time,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   557
     * then on the zone ID, then on the chronology.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   558
     * It is "consistent with equals", as defined by {@link Comparable}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   559
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   560
     * If all the date-time objects being compared are in the same chronology, then the
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   561
     * additional chronology stage is not required.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   562
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   563
     * This default implementation performs the comparison defined above.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   564
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   565
     * @param other  the other date-time to compare to, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   566
     * @return the comparator value, negative if less, positive if greater
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   567
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   568
    @Override
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   569
    default int compareTo(ChronoZonedDateTime<?> other) {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   570
        int cmp = Long.compare(toEpochSecond(), other.toEpochSecond());
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   571
        if (cmp == 0) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   572
            cmp = toLocalTime().getNano() - other.toLocalTime().getNano();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   573
            if (cmp == 0) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   574
                cmp = toLocalDateTime().compareTo(other.toLocalDateTime());
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   575
                if (cmp == 0) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   576
                    cmp = getZone().getId().compareTo(other.getZone().getId());
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   577
                    if (cmp == 0) {
20522
9a239bba214f 8024807: Add getChronlogy() to CLDT/CZDT
rriggs
parents: 20520
diff changeset
   578
                        cmp = getChronology().compareTo(other.getChronology());
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   579
                    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   580
                }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   581
            }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   582
        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   583
        return cmp;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   584
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   585
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   586
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   587
     * Checks if the instant of this date-time is before that of the specified date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   588
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   589
     * This method differs from the comparison in {@link #compareTo} in that it
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   590
     * only compares the instant of the date-time. This is equivalent to using
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   591
     * {@code dateTime1.toInstant().isBefore(dateTime2.toInstant());}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   592
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   593
     * This default implementation performs the comparison based on the epoch-second
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   594
     * and nano-of-second.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   595
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   596
     * @param other  the other date-time to compare to, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   597
     * @return true if this point is before the specified date-time
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   598
     */
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   599
    default boolean isBefore(ChronoZonedDateTime<?> other) {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   600
        long thisEpochSec = toEpochSecond();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   601
        long otherEpochSec = other.toEpochSecond();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   602
        return thisEpochSec < otherEpochSec ||
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   603
            (thisEpochSec == otherEpochSec && toLocalTime().getNano() < other.toLocalTime().getNano());
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   604
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   605
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   606
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   607
     * Checks if the instant of this date-time is after that of the specified date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   608
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   609
     * This method differs from the comparison in {@link #compareTo} in that it
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   610
     * only compares the instant of the date-time. This is equivalent to using
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   611
     * {@code dateTime1.toInstant().isAfter(dateTime2.toInstant());}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   612
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   613
     * This default implementation performs the comparison based on the epoch-second
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   614
     * and nano-of-second.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   615
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   616
     * @param other  the other date-time to compare to, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   617
     * @return true if this is after the specified date-time
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   618
     */
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   619
    default boolean isAfter(ChronoZonedDateTime<?> other) {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   620
        long thisEpochSec = toEpochSecond();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   621
        long otherEpochSec = other.toEpochSecond();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   622
        return thisEpochSec > otherEpochSec ||
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   623
            (thisEpochSec == otherEpochSec && toLocalTime().getNano() > other.toLocalTime().getNano());
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   624
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   625
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   626
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   627
     * Checks if the instant of this date-time is equal to that of the specified date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   628
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   629
     * This method differs from the comparison in {@link #compareTo} and {@link #equals}
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   630
     * in that it only compares the instant of the date-time. This is equivalent to using
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   631
     * {@code dateTime1.toInstant().equals(dateTime2.toInstant());}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   632
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   633
     * This default implementation performs the comparison based on the epoch-second
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   634
     * and nano-of-second.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   635
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   636
     * @param other  the other date-time to compare to, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   637
     * @return true if the instant equals the instant of the specified date-time
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   638
     */
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   639
    default boolean isEqual(ChronoZonedDateTime<?> other) {
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   640
        return toEpochSecond() == other.toEpochSecond() &&
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   641
                toLocalTime().getNano() == other.toLocalTime().getNano();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   642
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   643
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   644
    //-----------------------------------------------------------------------
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   645
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   646
     * Checks if this date-time is equal to another date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   647
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   648
     * The comparison is based on the offset date-time and the zone.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   649
     * To compare for the same instant on the time-line, use {@link #compareTo}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   650
     * Only objects of type {@code ChronoZonedDateTime} are compared, other types return false.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   651
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   652
     * @param obj  the object to check, null returns false
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   653
     * @return true if this is equal to the other date-time
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   654
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   655
    @Override
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   656
    boolean equals(Object obj);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   657
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   658
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   659
     * A hash code for this date-time.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   660
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   661
     * @return a suitable hash code
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   662
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   663
    @Override
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   664
    int hashCode();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   665
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   666
    //-----------------------------------------------------------------------
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   667
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   668
     * Outputs this date-time as a {@code String}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   669
     * <p>
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15658
diff changeset
   670
     * The output will include the full zoned date-time.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   671
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   672
     * @return a string representation of this date-time, not null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   673
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   674
    @Override
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   675
    String toString();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   676
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   677
}