public class Time extends Date
围绕java.util.Date类的薄包装,允许JDBC API将其标识为SQL TIME值。 Time类添加了格式化和解析操作,以支持时间值的JDBC转义语法。
日期组件应设置为1970年1月1日的“零纪元”值,不得访问。
| Constructor and Description |
|---|
Time(int hour, int minute, int second)
已弃用
使用构造函数,该构造函数需要一个毫秒值来代替此构造函数
|
Time(long time)
使用毫秒时间值构造一个
Time对象。
|
| Modifier and Type | Method and Description |
|---|---|
int |
getDate()
已弃用
|
int |
getDay()
已弃用
|
int |
getMonth()
已弃用
|
int |
getYear()
已弃用
|
void |
setDate(int i)
已弃用
|
void |
setMonth(int i)
已弃用
|
void |
setTime(long time)
使用毫秒时间值设置
Time对象。
|
void |
setYear(int i)
已弃用
|
Instant |
toInstant()
此方法总是引发UnsupportedOperationException,因为SQL
Time值不具有日期组件,因此不应该使用此方法。
|
LocalTime |
toLocalTime()
将此
Time对象转换为
LocalTime 。
|
String |
toString()
以JDBC时间转义格式格式化。
|
static Time |
valueOf(LocalTime time)
从 LocalTime对象获取Time的实例,具有与给定的LocalTime相同的小时,分秒和秒值。
|
static Time |
valueOf(String s)
将JDBC时间转义格式的字符串转换为
Time值。
|
after, before, clone, compareTo, equals, from, getHours, getMinutes, getSeconds, getTime, getTimezoneOffset, hashCode, parse, setHours, setMinutes, setSeconds, toGMTString, toLocaleString, UTC@Deprecated public Time(int hour, int minute, int second)
Time对象,该对象使用给定的小时,分钟和秒值进行初始化。
驱动程序将日期组件设置为1970年1月1日。尝试访问Time对象的日期组件的任何方法将抛出一个java.lang.IllegalArgumentException 。
如果给定的参数超出界限,结果是未定义的。
hour - 0至23
minute - 0至59
second - 0至59
public Time(long time)
Time对象。
time - 自1970年1月1日00:00:00 GMT以来的毫秒
负数是1970年1月1日00:00:00 GMT之前的毫秒
public void setTime(long time)
Time对象。
public static Time valueOf(String s)
Time值。
s - 时间格式“hh:mm:ss”
Time对象
public String toString()
toString在类别
Date
String在hh:mm:ss格式
Date.toLocaleString() ,
Date.toGMTString()
@Deprecated public int getYear()
TIME值不具有年份组件。
getYear在类别
Date
IllegalArgumentException - 如果这个方法被调用
setYear(int)
@Deprecated public int getMonth()
TIME值不具有月份组件。
getMonth在类别
Date
IllegalArgumentException - 如果这个方法被调用
setMonth(int)
@Deprecated public int getDay()
TIME值不包含日组件。
getDay在类别
Date
IllegalArgumentException - 如果这个方法被调用
Calendar
@Deprecated public int getDate()
TIME值没有日期组件。
getDate在类别
Date
IllegalArgumentException - 如果这个方法被调用
setDate(int)
@Deprecated public void setYear(int i)
TIME值不具有年份。
setYear在类别
Date
i - 年值。
IllegalArgumentException - 如果这个方法被调用
getYear()
@Deprecated public void setMonth(int i)
TIME值不具有月份组件。
setMonth在类别
Date
i - 0-11之间的月份值。
IllegalArgumentException - 如果这个方法被调用
getMonth()
@Deprecated public void setDate(int i)
TIME值不具有日期组件。
setDate在类别
Date
i -
i的一天值在1-31之间。
IllegalArgumentException - 如果这个方法被调用
getDate()
public static Time valueOf(LocalTime time)
LocalTime对象获取Time的实例,具有与给定的LocalTime相同的小时,分和秒时间值。
time - a
LocalTime转换
Time对象
NullPointerException - 如果
time为空
public LocalTime toLocalTime()
Time对象转换为LocalTime 。
转换创建LocalTime表示相同的小时,分钟,和作为该第二时间值Time 。
LocalTime相同时间值的
LocalTime对象
public Instant toInstant()
Time值没有日期组件,因此不应该使用此方法。
toInstant在类别
Date
Date对象的时间线上的相同点
UnsupportedOperationException - 如果调用此方法
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.