src/java.sql/share/classes/java/sql/Time.java
author weijun
Tue, 21 May 2019 08:37:30 +0800
changeset 58618 a95e1f6757c7
parent 48065 c4f2b6749c86
permissions -rw-r--r--
8224025: Fix for JDK-8220302 is not complete Reviewed-by: ahgross, mullan, valeriep
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
     2
 * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.sql;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
    28
import java.time.Instant;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
    29
import java.time.LocalTime;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
    30
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * <P>A thin wrapper around the <code>java.util.Date</code> class that allows the JDBC
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * API to identify this as an SQL <code>TIME</code> value. The <code>Time</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * class adds formatting and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * parsing operations to support the JDBC escape syntax for time
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <p>The date components should be set to the "zero epoch"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * value of January 1, 1970 and should not be accessed.
44256
12050b22e372 8176721: @since value errors java.sql module
mli
parents: 41889
diff changeset
    39
 *
12050b22e372 8176721: @since value errors java.sql module
mli
parents: 41889
diff changeset
    40
 * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
public class Time extends java.util.Date {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * Constructs a <code>Time</code> object initialized with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * given values for the hour, minute, and second.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * The driver sets the date components to January 1, 1970.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * Any method that attempts to access the date components of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * <code>Time</code> object will throw a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * <code>java.lang.IllegalArgumentException</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * The result is undefined if a given argument is out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * @param hour 0 to 23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * @param minute 0 to 59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * @param second 0 to 59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * @deprecated Use the constructor that takes a milliseconds value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *             in place of this constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
    61
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public Time(int hour, int minute, int second) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        super(70, 0, 1, hour, minute, second);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Constructs a <code>Time</code> object using a milliseconds time value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @param time milliseconds since January 1, 1970, 00:00:00 GMT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     *             a negative number is milliseconds before
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *               January 1, 1970, 00:00:00 GMT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public Time(long time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        super(time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Sets a <code>Time</code> object using a milliseconds time value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @param time milliseconds since January 1, 1970, 00:00:00 GMT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *             a negative number is milliseconds before
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *               January 1, 1970, 00:00:00 GMT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public void setTime(long time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        super.setTime(time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * Converts a string in JDBC time escape format to a <code>Time</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @param s time in format "hh:mm:ss"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @return a corresponding <code>Time</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public static Time valueOf(String s) {
26596
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
    95
        if (s == null) throw new java.lang.IllegalArgumentException();
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
    96
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        int hour;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        int minute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        int second;
26596
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   100
        int firstColon = s.indexOf(':');
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   101
        int secondColon = s.indexOf(':', firstColon + 1);
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   102
        int len = s.length();
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   103
        if (firstColon > 0 && secondColon > 0 &&
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   104
                secondColon < len - 1) {
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   105
            hour = Integer.parseInt(s, 0, firstColon, 10);
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   106
            minute = Integer.parseInt(s, firstColon + 1, secondColon, 10);
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   107
            second = Integer.parseInt(s, secondColon + 1, len, 10);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        return new Time(hour, minute, second);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * Formats a time in JDBC time escape format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @return a <code>String</code> in hh:mm:ss format
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
11129
f9ad1aadf3fa 7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents: 5506
diff changeset
   120
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public String toString () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        int hour = super.getHours();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        int minute = super.getMinutes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        int second = super.getSeconds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
26597
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   126
        char[] buf = new char[8];
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   127
        Date.formatDecimalInt(hour, buf, 0, 2);
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   128
        buf[2] = ':';
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   129
        Date.formatDecimalInt(minute, buf, 3, 2);
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   130
        buf[5] = ':';
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   131
        Date.formatDecimalInt(second, buf, 6, 2);
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   132
48065
c4f2b6749c86 8176188: jdk/internal/misc/JavaLangAccess/NewUnsafeString.java failing since 9-b93
redestad
parents: 47216
diff changeset
   133
        return new String(buf);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    // Override all the date operations inherited from java.util.Date;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    * values do not have a year component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    * @see #setYear
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   147
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public int getYear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    * values do not have a month component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    * @see #setMonth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   161
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    public int getMonth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    * values do not have a day component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   174
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    public int getDay() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    * values do not have a date component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    * @see #setDate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   188
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public int getDate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    * values do not have a year component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    * @see #getYear
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   202
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public void setYear(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    * values do not have a month component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    * @see #getMonth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   216
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public void setMonth(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    * values do not have a date component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    * @see #getDate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   230
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public void setDate(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    * Private serial version unique ID to ensure serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    * compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    static final long serialVersionUID = 8397324403548013681L;
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   240
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   241
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   242
     * Obtains an instance of {@code Time} from a {@link LocalTime} object
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   243
     * with the same hour, minute and second time value as the given
23707
4580f737d5b9 8038653: Fix Time.toLocalTime, Time.valueOf javadoc clarification
lancea
parents: 23010
diff changeset
   244
     * {@code LocalTime}. The nanosecond field from {@code LocalTime} is
4580f737d5b9 8038653: Fix Time.toLocalTime, Time.valueOf javadoc clarification
lancea
parents: 23010
diff changeset
   245
     * not part of the newly created {@code Time} object.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   246
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   247
     * @param time a {@code LocalTime} to convert
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   248
     * @return a {@code Time} object
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   249
     * @exception NullPointerException if {@code time} is null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   250
     * @since 1.8
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   251
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   252
    @SuppressWarnings("deprecation")
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   253
    public static Time valueOf(LocalTime time) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   254
        return new Time(time.getHour(), time.getMinute(), time.getSecond());
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   255
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   256
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   257
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   258
     * Converts this {@code Time} object to a {@code LocalTime}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   259
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   260
     * The conversion creates a {@code LocalTime} that represents the same
23707
4580f737d5b9 8038653: Fix Time.toLocalTime, Time.valueOf javadoc clarification
lancea
parents: 23010
diff changeset
   261
     * hour, minute, and second time value as this {@code Time}. The
4580f737d5b9 8038653: Fix Time.toLocalTime, Time.valueOf javadoc clarification
lancea
parents: 23010
diff changeset
   262
     * nanosecond {@code LocalTime} field will be set to zero.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   263
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   264
     * @return a {@code LocalTime} object representing the same time value
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   265
     * @since 1.8
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   266
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   267
    @SuppressWarnings("deprecation")
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   268
    public LocalTime toLocalTime() {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   269
        return LocalTime.of(getHours(), getMinutes(), getSeconds());
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   270
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   271
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   272
   /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   273
    * This method always throws an UnsupportedOperationException and should
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   274
    * not be used because SQL {@code Time} values do not have a date
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   275
    * component.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   276
    *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   277
    * @exception java.lang.UnsupportedOperationException if this method is invoked
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   278
    */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   279
    @Override
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   280
    public Instant toInstant() {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   281
        throw new java.lang.UnsupportedOperationException();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   282
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
}