JavaTM 2 Platform
Standard Ed. 6

java.sql
类 Time

java.lang.Object
  继承者 java.util.Date
      继承者 java.sql.Time
所有已实现的接口:
Serializable, Cloneable, Comparable<Date>

public class Time
extends Date

一个与 java.util.Date 类有关的瘦包装器 (thin wrapper),它允许 JDBC 将该类标识为 SQL TIME 值。Time 类添加格式化和解析操作以支持时间值的 JDBC 转义语法。

应该将日期组件设置为 1970 年 1 月 1 日的 "zero epoch" 值并且不应访问该值。

另请参见:
序列化表格

构造方法摘要
Time(int hour, int minute, int second)
          已过时。 使用采用毫秒值的构造方法取代此构造方法
Time(long time)
          使用毫秒时间值构造 Time 对象。
 
方法摘要
 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)
          已过时。  
 String toString()
          使用 JDBC 时间转义格式对时间进行格式化。
static Time valueOf(String s)
          将使用 JDBC 时间转义格式的字符串转换为 Time 值。
 
从类 java.util.Date 继承的方法
after, before, clone, compareTo, equals, getHours, getMinutes, getSeconds, getTime, getTimezoneOffset, hashCode, parse, setHours, setMinutes, setSeconds, toGMTString, toLocaleString, UTC
 
从类 java.lang.Object 继承的方法
finalize, getClass, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

Time

@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

Time

public Time(long time)
使用毫秒时间值构造 Time 对象。

参数:
time - 自从 1970 年 1 月 1 日 00:00:00 GMT 以来的毫秒数;负数表示在 1970 年 1 月 1 日 00:00:00 GMT 之前的毫秒数
方法详细信息

setTime

public void setTime(long time)
使用毫秒时间值设置 Time 对象。

覆盖:
Date 中的 setTime
参数:
time - 自从 1970 年 1 月 1 日 00:00:00 GMT 以来的毫秒数;负数表示在 1970 年 1 月 1 日 00:00:00 GMT 之前的毫秒数

valueOf

public static Time valueOf(String s)
将使用 JDBC 时间转义格式的字符串转换为 Time 值。

参数:
s - 使用 "hh:mm:ss" 格式的时间
返回:
相应的 Time 对象

toString

public String toString()
使用 JDBC 时间转义格式对时间进行格式化。

覆盖:
Date 中的 toString
返回:
使用 hh:mm:ss 格式的 String
另请参见:
Date.toLocaleString(), Date.toGMTString()

getYear

@Deprecated
public int getYear()
已过时。 

此方法已不建议使用并且不应再使用,因为 SQL TIME 值没有年 (year) 组件。

覆盖:
Date 中的 getYear
返回:
日期表示的年份减去 1900。
抛出:
IllegalArgumentException - 如果调用此方法
另请参见:
setYear(int)

getMonth

@Deprecated
public int getMonth()
已过时。 

此方法已不建议使用并且不应再使用,因为 SQL TIME 值没有月 (month) 组件。

覆盖:
Date 中的 getMonth
返回:
此日期所表示的月份。
抛出:
IllegalArgumentException - 如果调用此方法
另请参见:
setMonth(int)

getDay

@Deprecated
public int getDay()
已过时。 

此方法已不建议使用并且不应再使用,因为 SQL TIME 值没有日 (day) 组件。

覆盖:
Date 中的 getDay
返回:
此日期所表示的一周中的某一天。
抛出:
IllegalArgumentException - 如果调用此方法
另请参见:
Calendar

getDate

@Deprecated
public int getDate()
已过时。 

此方法已不建议使用并且不应再使用,因为 SQL TIME 值没有日期 (date) 组件。

覆盖:
Date 中的 getDate
返回:
此日期所表示的月份中的某一天。
抛出:
IllegalArgumentException - 如果调用此方法
另请参见:
setDate(int)

setYear

@Deprecated
public void setYear(int i)
已过时。 

此方法已不建议使用并且不应再使用,因为 SQL TIME 值没有年 (year) 组件。

覆盖:
Date 中的 setYear
参数:
i - 年份值。
抛出:
IllegalArgumentException - 如果调用此方法
另请参见:
getYear()

setMonth

@Deprecated
public void setMonth(int i)
已过时。 

此方法已不建议使用并且不应再使用,因为 SQL TIME 值没有月 (month) 组件。

覆盖:
Date 中的 setMonth
参数:
i - 0-11 之间的月份值。
抛出:
IllegalArgumentException - 如果调用此方法
另请参见:
getMonth()

setDate

@Deprecated
public void setDate(int i)
已过时。 

此方法已不建议使用并且不应再使用,因为 SQL TIME 值没有日期 (date) 组件。

覆盖:
Date 中的 setDate
参数:
i - 月份中 1-31 之间的某一天。
抛出:
IllegalArgumentException - 如果调用此方法
另请参见:
getDate()

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only