Added in API level 1

Time

public class Time
extends Date

java.lang.Object
   ↳ java.util.Date
     ↳ java.sql.Time


A thin wrapper around the java.util.Date class that allows the JDBC API to identify this as an SQL TIME value. The Time class adds formatting and parsing operations to support the JDBC escape syntax for time values.

The date components should be set to the "zero epoch" value of January 1, 1970 and should not be accessed.

Summary

Public constructors

Time(int hour, int minute, int second)

This constructor is deprecated. Use the constructor that takes a milliseconds value in place of this constructor

Time(long time)

Constructs a Time object using a milliseconds time value.

Public methods

int getDate()

This method is deprecated. This method is deprecated and should not be used because SQL TIME values do not have a date component.

int getDay()

This method is deprecated. This method is deprecated and should not be used because SQL TIME values do not have a day component.

int getMonth()

This method is deprecated. This method is deprecated and should not be used because SQL TIME values do not have a month component.

int getYear()

This method is deprecated. This method is deprecated and should not be used because SQL TIME values do not have a year component.

void setDate(int i)

This method is deprecated. This method is deprecated and should not be used because SQL TIME values do not have a date component.

void setMonth(int i)

This method is deprecated. This method is deprecated and should not be used because SQL TIME values do not have a month component.

void setTime(long time)

Sets a Time object using a milliseconds time value.

void setYear(int i)

This method is deprecated. This method is deprecated and should not be used because SQL TIME values do not have a year component.

String toString()

Formats a time in JDBC time escape format.

static Time valueOf(String s)

Converts a string in JDBC time escape format to a Time value.

Inherited methods

Public constructors

Time

Added in API level 1
public Time (int hour, 
                int minute, 
                int second)

This constructor is deprecated.
Use the constructor that takes a milliseconds value in place of this constructor

Constructs a Time object initialized with the given values for the hour, minute, and second. The driver sets the date components to January 1, 1970. Any method that attempts to access the date components of a Time object will throw a java.lang.IllegalArgumentException.

The result is undefined if a given argument is out of bounds.

Parameters
hour int: 0 to 23

minute int: 0 to 59

second int: 0 to 59

Time

Added in API level 1
public Time (long time)

Constructs a Time object using a milliseconds time value.

Parameters
time long: milliseconds since January 1, 1970, 00:00:00 GMT; a negative number is milliseconds before January 1, 1970, 00:00:00 GMT

Public methods

getDate

Added in API level 1
public int getDate ()

This method is deprecated.
This method is deprecated and should not be used because SQL TIME values do not have a date component.

Returns the day of the month represented by this Date object. The value returned is between 1 and 31 representing the day of the month that contains or begins with the instant in time represented by this Date object, as interpreted in the local time zone.

Returns
int the day of the month represented by this date.

Throws
IllegalArgumentException if this method is invoked

See also:

getDay

Added in API level 1
public int getDay ()

This method is deprecated.
This method is deprecated and should not be used because SQL TIME values do not have a day component.

Returns the day of the week represented by this date. The returned value (0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday) represents the day of the week that contains or begins with the instant in time represented by this Date object, as interpreted in the local time zone.

Returns
int the day of the week represented by this date.

Throws
IllegalArgumentException if this method is invoked

getMonth

Added in API level 1
public int getMonth ()

This method is deprecated.
This method is deprecated and should not be used because SQL TIME values do not have a month component.

Returns a number representing the month that contains or begins with the instant in time represented by this Date object. The value returned is between 0 and 11, with the value 0 representing January.

Returns
int the month represented by this date.

Throws
IllegalArgumentException if this method is invoked

See also:

getYear

Added in API level 1
public int getYear ()

This method is deprecated.
This method is deprecated and should not be used because SQL TIME values do not have a year component.

Returns a value that is the result of subtracting 1900 from the year that contains or begins with the instant in time represented by this Date object, as interpreted in the local time zone.

Returns
int the year represented by this date, minus 1900.

Throws
IllegalArgumentException if this method is invoked

See also:

setDate

Added in API level 1
public void setDate (int i)

This method is deprecated.
This method is deprecated and should not be used because SQL TIME values do not have a date component.

Sets the day of the month of this Date object to the specified value. This Date object is modified so that it represents a point in time within the specified day of the month, with the year, month, hour, minute, and second the same as before, as interpreted in the local time zone. If the date was April 30, for example, and the date is set to 31, then it will be treated as if it were on May 1, because April has only 30 days.

Parameters
i int: the day of the month value between 1-31.

Throws
IllegalArgumentException if this method is invoked

See also:

setMonth

Added in API level 1
public void setMonth (int i)

This method is deprecated.
This method is deprecated and should not be used because SQL TIME values do not have a month component.

Sets the month of this date to the specified value. This Date object is modified so that it represents a point in time within the specified month, with the year, date, hour, minute, and second the same as before, as interpreted in the local time zone. If the date was October 31, for example, and the month is set to June, then the new date will be treated as if it were on July 1, because June has only 30 days.

Parameters
i int: the month value between 0-11.

Throws
IllegalArgumentException if this method is invoked

See also:

setTime

Added in API level 1
public void setTime (long time)

Sets a Time object using a milliseconds time value.

Parameters
time long: milliseconds since January 1, 1970, 00:00:00 GMT; a negative number is milliseconds before January 1, 1970, 00:00:00 GMT

setYear

Added in API level 1
public void setYear (int i)

This method is deprecated.
This method is deprecated and should not be used because SQL TIME values do not have a year component.

Sets the year of this Date object to be the specified value plus 1900. This Date object is modified so that it represents a point in time within the specified year, with the month, date, hour, minute, and second the same as before, as interpreted in the local time zone. (Of course, if the date was February 29, for example, and the year is set to a non-leap year, then the new date will be treated as if it were on March 1.)

Parameters
i int: the year value.

Throws
IllegalArgumentException if this method is invoked

See also:

toString

Added in API level 1
public String toString ()

Formats a time in JDBC time escape format.

Returns
String a String in hh:mm:ss format

valueOf

Added in API level 1
public static Time valueOf (String s)

Converts a string in JDBC time escape format to a Time value.

Parameters
s String: time in format "hh:mm:ss"

Returns
Time a corresponding Time object