java.sql

Class Time

Implemented Interfaces:
Cloneable, Comparable<T>, Serializable

public class Time
extends Date

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.

See Also:
Serialized Form

Constructor Summary

Time(long time)
Constructs a Time object using a milliseconds time value.

Method Summary

@Deprecated
int getDate()
Deprecated.
@Deprecated
int getDay()
Deprecated.
@Deprecated
int getMonth()
Deprecated.
@Deprecated
int getYear()
Deprecated.
void
setTime(long time)
Sets a Time object using a milliseconds time value.
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.
@Deprecated
void setDate(int i)
Deprecated.
@Deprecated
void setMonth(int i)
Deprecated.
@Deprecated
void setYear(int i)
Deprecated.

Methods inherited from class java.util.Date

String toGMTString, String toLocaleString, after, before, clone, compareTo, equals, getTime, hashCode, int getDate, int getDay, int getHours, int getMinutes, int getMonth, int getSeconds, int getTimezoneOffset, int getYear, long UTC, long parse, setTime, toString, void setDate, void setHours, void setMinutes, void setMonth, void setSeconds, void setYear

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Time

public Time(long time)
Constructs a Time object using a milliseconds time value.
Parameters:
time - milliseconds since January 1, 1970, 00:00:00 GMT; a negative number is milliseconds before January 1, 1970, 00:00:00 GMT
Usages and Demos :

View More Examples of Time(long time)
   1:         else {
   2:             time = new Time( ( (java.util.Date) value ).getTime() );
   3:         }
   4:         st.setTime(index, time);
   5:     }

View Full Code Here
   1:         else {
   2:             time = new Time( ( (java.util.Date) value ).getTime() );
   3:         }
   4:         st.setTime(index, time);
   5:     }

View Full Code Here
   1:         else {
   2:             time = new Time( ( (java.util.Date) value ).getTime() );
   3:         }
   4:         ...
   5:     public Object deepCopyNotNull(Object value) {
   6:         return  new Time( ( (java.util.Date) value ).getTime() );
   7:     }
   8: 
   9:     public String objectToSQLString(Object value, Dialect dialect) throws Exception {

View Full Code Here
   1:                 Date date = DateFieldHandler.parse(str);
   2:                 time = new Time(date.getTime());
   3:             }
   4:         ...
   5:     {
   6:         return new java.sql.Time(0);
   7:     }
   8:     
   9:     

View Full Code Here
   1:         } else if (object.getClass() == ClassConstants.TIME) {
   2:             printString("new java.sql.Time(");
   3:             printString(String.valueOf(((java.sql.Time)object).getTime()));
   4:             printString("L)");
   5:         } else if (object.getClass() == ClassConstants.UTILDATE) {

View Full Code Here

Method Details

int getDate

public @Deprecated int getDate()

Deprecated.

This method is deprecated and should not be used because SQL TIME values do not have a date component.
Overrides:
int getDate in interface Date
Throws:
IllegalArgumentException - if this method is invoked
See Also:
Time

int getDay

public @Deprecated int getDay()

Deprecated.

This method is deprecated and should not be used because SQL TIME values do not have a day component.
Overrides:
int getDay in interface Date
Throws:
IllegalArgumentException - if this method is invoked

int getMonth

public @Deprecated int getMonth()

Deprecated.

This method is deprecated and should not be used because SQL TIME values do not have a month component.
Overrides:
int getMonth in interface Date
Throws:
IllegalArgumentException - if this method is invoked
See Also:
Time

int getYear

public @Deprecated int getYear()

Deprecated.

This method is deprecated and should not be used because SQL TIME values do not have a year component.
Overrides:
int getYear in interface Date
Throws:
IllegalArgumentException - if this method is invoked
See Also:
Time

setTime

public void setTime(long time)
Sets a Time object using a milliseconds time value.
Overrides:
setTime in interface Date
Parameters:
time - milliseconds since January 1, 1970, 00:00:00 GMT; a negative number is milliseconds before January 1, 1970, 00:00:00 GMT
Usages and Demos :

View More Examples of setTime(long time)
   1: import java.util.Date;
   2: import java.sql.Time;
   3: 
   4:         ...
   5: 
   6:     private static final String _xmlName = "sql-time";
   7: 
   8:         ...
   9:                         
  10:                     if (java.sql.Time.class == object.getClass()) {
  11:                         Time target = (Time)object;
  12:         ...
  13:                         if (java.util.Date.class.isAssignableFrom(value.getClass())) {
  14:                             target.setTime(((Date)value).getTime());

View Full Code Here

toString

public String toString()
Formats a time in JDBC time escape format.
Overrides:
toString in interface Date
Returns:
a String in hh:mm:ss format
Usages and Demos :

View More Examples of toString()
   1: 
   2: import java.sql.Time;
   3: import java.util.ArrayList;
   4:         ...
   5:             {
   6:                 Time obj = (Time) timeList.get(i);
   7:         ...
   8:                 String newSt = obj.toString();
   9:                 newSt = StringUtils.replace(newSt, "#", "##");
  10:         ...
  11:             }
  12:             return result.toString();

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.Time;
   3: import java.sql.SQLException;
   4:         ...
   5:     }
   6:     public Time getTime(Calendar cal) throws SQLException {
   7:         if (getFieldData()==null) return TIME_NULL_VALUE;
   8:         ...
   9:     }
  10:     public Time getTime() throws SQLException {
  11:         if (getFieldData()==null) return TIME_NULL_VALUE;
  12:         ...
  13:         
  14:         setString(value.toString());

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.Time;
   3: import java.sql.Timestamp;
   4:         ...
   5:                 Timestamp ts = PGDateTimeTypes.textToTimestamp(val);
   6:                 return Date.valueOf(ts.toString().substring(0, 10));
   7:             } else {
   8:         ...
   9: 
  10:      public static final Time getPGTime(String val) throws SQLException {
  11:         if (null == val) {
  12:         ...
  13:                 Timestamp ts = PGDateTimeTypes.textToTimestamp(val);
  14:                 return Time.valueOf(ts.toString().substring(11, 19));

View Full Code Here
   1:         } catch(SQLException e) {
   2:             trace(e.toString());
   3:         }
   4:         ...
   5:         } catch(SQLException e) {
   6:             trace(e.toString());
   7:         }
   8:         ...
   9:         check(o instanceof String);
  10:         check(o.toString().equals("Hi"));
  11:         
  12:         ...
  13:         java.sql.Date date;
  14:         java.sql.Time time;

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.Time;
   3: import java.sql.Timestamp;
   4:         ...
   5:         private PGtime() {
   6:             super("time");
   7:         }
   8:         ...
   9:         public String getLiteralSuffix() {
  10:             return "'::time";
  11:         }
  12:         ...
  13:             } else {
  14:                 data = pctx.getBytes(val.toString());

View Full Code Here

valueOf

public static Time valueOf(String s)
Converts a string in JDBC time escape format to a Time value.
Parameters:
s - time in format "hh:mm:ss"
Returns:
a corresponding Time object
Usages and Demos :

View More Examples of valueOf(String s)
   1: 
   2: import java.sql.Time;
   3: import java.util.*;
   4:         ...
   5:     private static void addAlbumTrack(Album album, String title, String file,
   6:                                       Time length, Artist artist, int disc,
   7:                                       int positionOnDisc, Session session)
   8:         ...
   9:             addAlbumTrack(album, "Compulsion", "vol1/album83/track01.mp3",
  10:                           Time.valueOf("00:05:29"), artist, 1, 1, session);
  11:             addAlbumTrack(album, "In a Manner of Speaking",
  12:         ...
  13:                           "vol1/album83/track02.mp3", Time.valueOf("00:04:21"),

View Full Code Here
   1: 
   2: import java.sql.Time;
   3: import java.util.*;
   4:         ...
   5:                                     "vol2/album610/track02.mp3",
   6:                                     Time.valueOf("00:03:30"), new Date(),
   7:                                     fullVolume, SourceMedia.CD,
   8:         ...
   9:                               "vol2/album611/track12.mp3",
  10:                               Time.valueOf("00:03:49"), new Date(),
  11:                               fullVolume, SourceMedia.VHS,
  12:         ...
  13:                               "vol2/album175/track03.mp3",
  14:                               Time.valueOf("00:06:06"), new Date(),

View Full Code Here
   1: import java.sql.Date;
   2: import java.sql.Time;
   3: import java.sql.SQLException;
   4:         ...
   5: 
   6:         return Date.valueOf(getString().trim());
   7:     }
   8:         ...
   9:     public Time getTime(Calendar cal) throws SQLException {
  10:         if (getFieldData()==null) return TIME_NULL_VALUE;
  11:         ...
  12:     }
  13:     public Time getTime() throws SQLException {

View Full Code Here

void setDate

public @Deprecated void setDate(int i)

Deprecated.

This method is deprecated and should not be used because SQL TIME values do not have a date component.
Overrides:
void setDate in interface Date
Throws:
IllegalArgumentException - if this method is invoked
See Also:
Time

void setMonth

public @Deprecated void setMonth(int i)

Deprecated.

This method is deprecated and should not be used because SQL TIME values do not have a month component.
Overrides:
void setMonth in interface Date
Throws:
IllegalArgumentException - if this method is invoked
See Also:
Time

void setYear

public @Deprecated void setYear(int i)

Deprecated.

This method is deprecated and should not be used because SQL TIME values do not have a year component.
Overrides:
void setYear in interface Date
Throws:
IllegalArgumentException - if this method is invoked
See Also:
Time