Package java.sql
Class Time
java.lang.Object
java.util.Date
java.sql.Time
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Date>
public class Time extends Date
Java representation of an SQL
TIME value. Provides utilities to
format and parse the time's representation as a String in JDBC escape format.- See Also:
- Serialized Form
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description intgetDate()Deprecated.This method is deprecated and must not be used.intgetDay()Deprecated.This method is deprecated and must not be used.intgetMonth()Deprecated.This method is deprecated and must not be used.intgetYear()Deprecated.This method is deprecated and must not be used.voidsetDate(int i)Deprecated.This method is deprecated and must not be used.voidsetMonth(int i)Deprecated.This method is deprecated and must not be used.voidsetTime(long time)Sets the time for thisTimeobject to the supplied milliseconds value.voidsetYear(int i)Deprecated.This method is deprecated and must not be used.StringtoString()Formats theTimeas a String in JDBC escape format:hh:mm:ss.static TimevalueOf(String timeString)Creates aTimeobject from a string holding a time represented in JDBC escape format:hh:mm:ss.Methods inherited from class java.util.Date
after, before, clone, compareTo, equals, getHours, getMinutes, getSeconds, getTime, getTimezoneOffset, hashCode, parse, setHours, setMinutes, setSeconds, toGMTString, toLocaleString, UTC
-
Constructor Details
-
Time
Deprecated.Use the constructorTime(long)instead.Constructs aTimeobject using the supplied values for Hour, Minute and Second. The Year, Month and Day elements of theTimeobject are set to the date of the Epoch (January 1, 1970).Any attempt to access the Year, Month or Day elements of a
Timeobject will result in anIllegalArgumentException.The result is undefined if any argument is out of bounds.
- Parameters:
theHour- a value in the range[0,23].theMinute- a value in the range[0,59].theSecond- a value in the range[0,59].
-
Time
public Time(long theTime)Constructs aTimeobject using a supplied time specified in milliseconds.- Parameters:
theTime- aTimespecified in milliseconds since the Epoch (January 1st 1970, 00:00:00.000).
-
-
Method Details
-
getDate
Deprecated.This method is deprecated and must not be used. An SQLTimeobject does not have a date component.Description copied from class:DateReturns the gregorian calendar day of the month for thisDateobject.- Overrides:
getDatein classDate- Returns:
- does not return anything.
- Throws:
IllegalArgumentException- if this method is called.
-
getDay
Deprecated.This method is deprecated and must not be used. An SQLTimeobject does not have a day component.Description copied from class:DateReturns the gregorian calendar day of the week for thisDateobject.- Overrides:
getDayin classDate- Returns:
- does not return anything.
- Throws:
IllegalArgumentException- if this method is called.
-
getMonth
Deprecated.This method is deprecated and must not be used. An SQLTimeobject does not have a month component.Description copied from class:DateReturns the gregorian calendar month for thisDateobject.- Overrides:
getMonthin classDate- Returns:
- does not return anything.
- Throws:
IllegalArgumentException- if this method is called.
-
getYear
Deprecated.This method is deprecated and must not be used. An SQLTimeobject does not have a year component.Description copied from class:DateReturns the gregorian calendar year since 1900 for thisDateobject.- Overrides:
getYearin classDate- Returns:
- does not return anything.
- Throws:
IllegalArgumentException- if this method is called.
-
setDate
Deprecated.This method is deprecated and must not be used. An SQLTimeobject does not have a date component.Description copied from class:DateSets the gregorian calendar day of the month for thisDateobject.- Overrides:
setDatein classDate- Parameters:
i- the day of the month.- Throws:
IllegalArgumentException- if this method is called.
-
setMonth
Deprecated.This method is deprecated and must not be used. An SQLTimeobject does not have a month component.Description copied from class:DateSets the gregorian calendar month for thisDateobject.- Overrides:
setMonthin classDate- Parameters:
i- the month.- Throws:
IllegalArgumentException- if this method is called.
-
setYear
Deprecated.This method is deprecated and must not be used. An SQLTimeobject does not have a year component.Description copied from class:DateSets the gregorian calendar year since 1900 for thisDateobject.- Overrides:
setYearin classDate- Parameters:
i- the year since 1900.- Throws:
IllegalArgumentException- if this method is called.
-
setTime
public void setTime(long time)Sets the time for thisTimeobject to the supplied milliseconds value. -
toString
Formats theTimeas a String in JDBC escape format:hh:mm:ss. -
valueOf
Creates aTimeobject from a string holding a time represented in JDBC escape format:hh:mm:ss.An exception occurs if the input string does not comply with this format.
- Parameters:
timeString- A String representing the time value in JDBC escape format:hh:mm:ss.- Returns:
- The
Timeobject set to a time corresponding to the given time. - Throws:
IllegalArgumentException- if the supplied time string is not in JDBC escape format.
-
Time(long)instead.