Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
net.sourceforge.jtds.jdbc.DateTime
public class DateTime
extends java.lang.Object
Field Summary | |
(package private) static int |
|
(package private) static int |
|
private static ThreadLocal |
|
private int |
|
private Date |
|
private short |
|
private short |
|
private short |
|
private short |
|
private short |
|
private short |
|
private String |
|
private int |
|
private Time |
|
private Timestamp |
|
private boolean |
|
private short |
|
Constructor Summary | |
| |
| |
| |
| |
|
Method Summary | |
(package private) int |
|
(package private) int |
|
void |
|
void |
|
Date |
|
Object |
|
String |
|
Time |
|
Timestamp |
|
private void |
|
(package private) static final int DATE_NOT_USED
Indicates date value not used.
(package private) static final int TIME_NOT_USED
Indicates time value not used.
private static ThreadLocal calendar
Per thread instance of Calendar used for conversions.
private int date
The date component of the server datetime value.
private Date dateValue
Cached value of the datetime as ajava.sql.Date
.
private short day
Unpacked day value.
private short hour
Unpacked hour value.
private short millis
Unpacked millisecond value.
private short minute
Unpacked minute value.
private short month
Unpacked month value.
private short second
Unpacked second value.
private String stringValue
Cached value of the datetime as aString
.
private int time
The time component of the server datetime value.
private Time timeValue
Cached value of the datetime as ajava.sql.Time
.
private Timestamp tsValue
Cached value of the datetime as ajava.sql.Timestamp
.
private boolean unpacked
Indicates server datetime values have been unpacked.
private short year
Unpacked year value.
(package private) DateTime(Date d) throws SQLException
Constructs a DateTime object from ajava.sql.Date
.
- Parameters:
d
-Date
object representing the datetime
(package private) DateTime(Time t)
Constructs a DateTime object from ajava.sql.Time
.
- Parameters:
t
-Time
object representing the datetime
(package private) DateTime(Timestamp ts) throws SQLException
Constructs a DateTime object from ajava.sql.Timestamp
.
- Parameters:
ts
-Timestamp
object representing the datetime
(package private) DateTime(int date, int time)
Constructs a DateTime object from the two integer components of a datetime.
- Parameters:
date
- server date fieldtime
- server time field
(package private) DateTime(short date, short time)
Constructs a DateTime object from the two short components of a smalldatetime.
- Parameters:
date
- server date fieldtime
- server time field
(package private) int getDate()
Retrieves the date component of a datetime value.
- Returns:
- the datetime date component as an
int
(package private) int getTime()
Retrieves the time component of a datetime value.
- Returns:
- the datetime time component as an
int
public void packDate() throws SQLException
Converts a calendar date into days since 1900 (Sybase epoch). Algorithm from Fliegel, H F and van Flandern, T C (1968). Communications of the ACM, Vol 11, No 10 (October, 1968).INTEGER FUNCTION JD (YEAR,MONTH,DAY) C C---COMPUTES THE JULIAN DATE (JD) GIVEN A GREGORIAN CALENDAR C DATE (YEAR,MONTH,DAY). C INTEGER YEAR,MONTH,DAY,I,J,K C I= YEAR J= MONTH K= DAY C JD= K-32075+1461*(I+4800+(J-14)/12)/4+367*(J-2-(J-14)/12*12) 2 /12-3*((I+4900+(J-14)/12)/100)/4 C RETURN END
public void packTime()
Converts separate time components into a datetime time value.
public Date toDate()
Retrieves the current datetime value as a Date.
- Returns:
- the current datetime value as a
java.sql.Date
public Object toObject()
Retrieves the current datetime value as a Time, Date or Timestamp.
- Returns:
- the current datetime value as an
java.lang.Object
public String toString()
Retrieves the current datetime value as a String.
- Returns:
- the current datetime value as a
String
public Time toTime()
Retrieves the current datetime value as a Time.
- Returns:
- the current datetime value as a
java.sql.Time
public Timestamp toTimestamp()
Retrieves the current datetime value as a Timestamp.
- Returns:
- the current datetime value as a
java.sql.Timestamp
private void unpackDateTime()
Converts a Julian datetime from the Sybase epoch of 1900-01-01 to the equivalent unpacked year/month/day etc. Algorithm from Fliegel, H F and van Flandern, T C (1968). Communications of the ACM, Vol 11, No 10 (October, 1968).SUBROUTINE GDATE (JD, YEAR,MONTH,DAY) C C---COMPUTES THE GREGORIAN CALENDAR DATE (YEAR,MONTH,DAY) C GIVEN THE JULIAN DATE (JD). C INTEGER JD,YEAR,MONTH,DAY,I,J,K C L= JD+68569 N= 4*L/146097 L= L-(146097*N+3)/4 I= 4000*(L+1)/1461001 L= L-1461*I/4+31 J= 80*L/2447 K= L-2447*J/80 L= J/11 J= J+2-12*L I= 100*(N-49)+I+L C YEAR= I MONTH= J DAY= K C RETURN END