Skip to content

Most visited

Recently visited

navigation
Added in API level 1

Time

public class Time
extends Date

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


Java representation of an SQL TIME value. Provides utilities to format and parse the time's representation as a String in JDBC escape format.

Summary

Public constructors

Time(int theHour, int theMinute, int theSecond)

This constructor was deprecated in API level 1. Use the constructor Time(long) instead.

Time(long theTime)

Constructs a Time object using a supplied time specified in milliseconds.

Public methods

int getDate()

This method is deprecated. This method is deprecated and must not be used. An SQL Time object does not have a date component.

int getDay()

This method is deprecated. This method is deprecated and must not be used. An SQL Time object does not have a day component.

int getMonth()

This method is deprecated. This method is deprecated and must not be used. An SQL Time object does not have a month component.

int getYear()

This method is deprecated. This method is deprecated and must not be used. An SQL Time object does not have a year component.

void setDate(int i)

This method is deprecated. This method is deprecated and must not be used. An SQL Time object does not have a date component.

void setMonth(int i)

This method is deprecated. This method is deprecated and must not be used. An SQL Time object does not have a month component.

void setTime(long time)

Sets the time for this Time object to the supplied milliseconds value.

void setYear(int i)

This method is deprecated. This method is deprecated and must not be used. An SQL Time object does not have a year component.

String toString()

Formats the Time as a String in JDBC escape format: hh:mm:ss.

static Time valueOf(String timeString)

Creates a Time object from a string holding a time represented in JDBC escape format: hh:mm:ss.

Inherited methods

From class java.util.Date
From class java.lang.Object
From interface java.lang.Comparable

Public constructors

Time

Added in API level 1
Time (int theHour, 
                int theMinute, 
                int theSecond)

This constructor was deprecated in API level 1.
Use the constructor Time(long) instead.

Constructs a Time object using the supplied values for Hour, Minute and Second. The Year, Month and Day elements of the Time object are set to the date of the Epoch (January 1, 1970).

Any attempt to access the Year, Month or Day elements of a Time object will result in an IllegalArgumentException.

The result is undefined if any argument is out of bounds.

Parameters
theHour int: a value in the range [0,23].
theMinute int: a value in the range [0,59].
theSecond int: a value in the range [0,59].

Time

Added in API level 1
Time (long theTime)

Constructs a Time object using a supplied time specified in milliseconds.

Parameters
theTime long: a Time specified in milliseconds since the Epoch (January 1st 1970, 00:00:00.000).

Public methods

getDate

Added in API level 1
int getDate ()

This method is deprecated.
This method is deprecated and must not be used. An SQL Time object does not have a date component.

Returns the gregorian calendar day of the month for this Date object.

Returns
int does not return anything.
Throws
IllegalArgumentException if this method is called.

getDay

Added in API level 1
int getDay ()

This method is deprecated.
This method is deprecated and must not be used. An SQL Time object does not have a day component.

Returns the gregorian calendar day of the week for this Date object.

Returns
int does not return anything.
Throws
IllegalArgumentException if this method is called.

getMonth

Added in API level 1
int getMonth ()

This method is deprecated.
This method is deprecated and must not be used. An SQL Time object does not have a month component.

Returns the gregorian calendar month for this Date object.

Returns
int does not return anything.
Throws
IllegalArgumentException if this method is called.

getYear

Added in API level 1
int getYear ()

This method is deprecated.
This method is deprecated and must not be used. An SQL Time object does not have a year component.

Returns the gregorian calendar year since 1900 for this Date object.

Returns
int does not return anything.
Throws
IllegalArgumentException if this method is called.

setDate

Added in API level 1
void setDate (int i)

This method is deprecated.
This method is deprecated and must not be used. An SQL Time object does not have a date component.

Sets the gregorian calendar day of the month for this Date object.

Parameters
i int: the day of the month.
Throws
IllegalArgumentException if this method is called.

setMonth

Added in API level 1
void setMonth (int i)

This method is deprecated.
This method is deprecated and must not be used. An SQL Time object does not have a month component.

Sets the gregorian calendar month for this Date object.

Parameters
i int: the month.
Throws
IllegalArgumentException if this method is called.

setTime

Added in API level 1
void setTime (long time)

Sets the time for this Time object to the supplied milliseconds value.

Parameters
time long: A time value expressed as milliseconds since the Epoch. Negative values are milliseconds before the Epoch. The Epoch is January 1 1970, 00:00:00.000.

setYear

Added in API level 1
void setYear (int i)

This method is deprecated.
This method is deprecated and must not be used. An SQL Time object does not have a year component.

Sets the gregorian calendar year since 1900 for this Date object.

Parameters
i int: the year since 1900.
Throws
IllegalArgumentException if this method is called.

toString

Added in API level 1
String toString ()

Formats the Time as a String in JDBC escape format: hh:mm:ss.

Returns
String A String representing the Time value in JDBC escape format: HH:mm:ss

valueOf

Added in API level 1
Time valueOf (String timeString)

Creates a Time object 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 String: A String representing the time value in JDBC escape format: hh:mm:ss.
Returns
Time The Time object set to a time corresponding to the given time.
Throws
IllegalArgumentException if the supplied time string is not in JDBC escape format.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.