jdk/src/java.sql/share/classes/java/sql/Time.java
author lana
Thu, 13 Jul 2017 17:32:50 +0000
changeset 46004 df6671f0f8f3
parent 41889 54d1ff9312ce
child 44256 12050b22e372
permissions -rw-r--r--
Added tag jdk-9+178 for changeset df8265c4f940
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;
32834
e1dca5fe4de3 8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents: 26597
diff changeset
    30
import jdk.internal.misc.SharedSecrets;
e1dca5fe4de3 8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents: 26597
diff changeset
    31
import jdk.internal.misc.JavaLangAccess;
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
    32
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <P>A thin wrapper around the <code>java.util.Date</code> class that allows the JDBC
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * API to identify this as an SQL <code>TIME</code> value. The <code>Time</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * class adds formatting and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * parsing operations to support the JDBC escape syntax for time
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <p>The date components should be set to the "zero epoch"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * value of January 1, 1970 and should not be accessed.
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
26597
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
    44
    private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
    45
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * Constructs a <code>Time</code> object initialized with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * given values for the hour, minute, and second.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * The driver sets the date components to January 1, 1970.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * Any method that attempts to access the date components of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * <code>Time</code> object will throw a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * <code>java.lang.IllegalArgumentException</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * The result is undefined if a given argument is out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * @param hour 0 to 23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * @param minute 0 to 59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * @param second 0 to 59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @deprecated Use the constructor that takes a milliseconds value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *             in place of this constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
    63
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public Time(int hour, int minute, int second) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        super(70, 0, 1, hour, minute, second);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Constructs a <code>Time</code> object using a milliseconds time value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @param time milliseconds since January 1, 1970, 00:00:00 GMT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     *             a negative number is milliseconds before
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *               January 1, 1970, 00:00:00 GMT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public Time(long time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        super(time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * Sets a <code>Time</code> object using a milliseconds time value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @param time milliseconds since January 1, 1970, 00:00:00 GMT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *             a negative number is milliseconds before
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *               January 1, 1970, 00:00:00 GMT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public void setTime(long time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        super.setTime(time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * Converts a string in JDBC time escape format to a <code>Time</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @param s time in format "hh:mm:ss"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @return a corresponding <code>Time</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public static Time valueOf(String s) {
26596
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
    97
        if (s == null) throw new java.lang.IllegalArgumentException();
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
    98
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        int hour;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        int minute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        int second;
26596
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   102
        int firstColon = s.indexOf(':');
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   103
        int secondColon = s.indexOf(':', firstColon + 1);
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   104
        int len = s.length();
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   105
        if (firstColon > 0 && secondColon > 0 &&
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   106
                secondColon < len - 1) {
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   107
            hour = Integer.parseInt(s, 0, firstColon, 10);
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   108
            minute = Integer.parseInt(s, firstColon + 1, secondColon, 10);
85ea379d419a 8055055: Improve numeric parsing in java.sql
redestad
parents: 25859
diff changeset
   109
            second = Integer.parseInt(s, secondColon + 1, len, 10);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        return new Time(hour, minute, second);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * Formats a time in JDBC time escape format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @return a <code>String</code> in hh:mm:ss format
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
11129
f9ad1aadf3fa 7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents: 5506
diff changeset
   122
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    public String toString () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        int hour = super.getHours();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        int minute = super.getMinutes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        int second = super.getSeconds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
26597
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   128
        char[] buf = new char[8];
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   129
        Date.formatDecimalInt(hour, buf, 0, 2);
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   130
        buf[2] = ':';
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   131
        Date.formatDecimalInt(minute, buf, 3, 2);
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   132
        buf[5] = ':';
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   133
        Date.formatDecimalInt(second, buf, 6, 2);
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   134
c840e6631327 8058230: Improve java.sql toString formatting
redestad
parents: 26596
diff changeset
   135
        return jla.newStringUnsafe(buf);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    // Override all the date operations inherited from java.util.Date;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    * values do not have a year component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    * @see #setYear
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   149
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public int getYear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    * values do not have a month component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    * @see #setMonth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   163
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public int getMonth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    * values do not have a day component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   176
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public int getDay() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    * values do not have a date component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    * @see #setDate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   190
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    public int getDate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    * values do not have a year component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    * @see #getYear
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   204
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public void setYear(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    * values do not have a month component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    * @see #getMonth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   218
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public void setMonth(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    * This method is deprecated and should not be used because SQL <code>TIME</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    * values do not have a date component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    * @exception java.lang.IllegalArgumentException if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    *           method is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    * @see #getDate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    */
41889
54d1ff9312ce 8169020: Add since element to JDBC deprecated methods
lancea
parents: 32834
diff changeset
   232
    @Deprecated(since="1.2")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    public void setDate(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        throw new java.lang.IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    * Private serial version unique ID to ensure serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    * compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    static final long serialVersionUID = 8397324403548013681L;
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   242
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   243
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   244
     * Obtains an instance of {@code Time} from a {@link LocalTime} object
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   245
     * 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
   246
     * {@code LocalTime}. The nanosecond field from {@code LocalTime} is
4580f737d5b9 8038653: Fix Time.toLocalTime, Time.valueOf javadoc clarification
lancea
parents: 23010
diff changeset
   247
     * not part of the newly created {@code Time} object.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   248
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   249
     * @param time a {@code LocalTime} to convert
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   250
     * @return a {@code Time} object
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   251
     * @exception NullPointerException if {@code time} is null
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   252
     * @since 1.8
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   253
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   254
    @SuppressWarnings("deprecation")
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   255
    public static Time valueOf(LocalTime time) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   256
        return new Time(time.getHour(), time.getMinute(), time.getSecond());
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
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   259
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   260
     * Converts this {@code Time} object to a {@code LocalTime}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   261
     * <p>
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   262
     * 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
   263
     * 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
   264
     * nanosecond {@code LocalTime} field will be set to zero.
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   265
     *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   266
     * @return a {@code LocalTime} object representing the same time value
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   267
     * @since 1.8
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   268
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   269
    @SuppressWarnings("deprecation")
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   270
    public LocalTime toLocalTime() {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   271
        return LocalTime.of(getHours(), getMinutes(), getSeconds());
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
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   274
   /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   275
    * This method always throws an UnsupportedOperationException and should
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   276
    * 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
   277
    * component.
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
    * @exception java.lang.UnsupportedOperationException if this method is invoked
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   280
    */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   281
    @Override
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   282
    public Instant toInstant() {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   283
        throw new java.lang.UnsupportedOperationException();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents: 14342
diff changeset
   284
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
}