|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jtds.jdbc.DateTime
Encapsulates Sybase date/time values and provides conversions to and from Java classes.
Field Summary | |
private static java.lang.ThreadLocal |
calendar
Per thread instance of Calendar used for conversions. |
private int |
date
The date component of the server datetime value. |
(package private) static int |
DATE_NOT_USED
Indicates date value not used. |
private java.sql.Date |
dateValue
Cached value of the datetime as a java.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 java.lang.String |
stringValue
Cached value of the datetime as a String . |
private int |
time
The time component of the server datetime value. |
(package private) static int |
TIME_NOT_USED
Indicates time value not used. |
private java.sql.Time |
timeValue
Cached value of the datetime as a java.sql.Time . |
private java.sql.Timestamp |
tsValue
Cached value of the datetime as a java.sql.Timestamp . |
private boolean |
unpacked
Indicates server datetime values have been unpacked. |
private short |
year
Unpacked year value. |
Constructor Summary | |
(package private) |
DateTime(java.sql.Date d)
Constructs a DateTime object from a java.sql.Date . |
(package private) |
DateTime(int date,
int time)
Constructs a DateTime object from the two integer components of a datetime. |
(package private) |
DateTime(short date,
short time)
Constructs a DateTime object from the two short components of a smalldatetime. |
(package private) |
DateTime(java.sql.Time t)
Constructs a DateTime object from a java.sql.Time . |
(package private) |
DateTime(java.sql.Timestamp ts)
Constructs a DateTime object from a java.sql.Timestamp . |
Method Summary | |
(package private) int |
getDate()
Retrieves the date component of a datetime value. |
(package private) int |
getTime()
Retrieves the time component of a datetime value. |
void |
packDate()
Converts a calendar date into days since 1900 (Sybase epoch). |
void |
packTime()
Converts separate time components into a datetime time value. |
java.sql.Date |
toDate()
Retrieves the current datetime value as a Date. |
java.lang.Object |
toObject()
Retrieves the current datetime value as a Time, Date or Timestamp. |
java.lang.String |
toString()
Retrieves the current datetime value as a String. |
java.sql.Time |
toTime()
Retrieves the current datetime value as a Time. |
java.sql.Timestamp |
toTimestamp()
Retrieves the current datetime value as a Timestamp. |
private void |
unpackDateTime()
Converts a Julian datetime from the Sybase epoch of 1900-01-01 to the equivalent unpacked year/month/day etc. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static java.lang.ThreadLocal calendar
static final int DATE_NOT_USED
static final int TIME_NOT_USED
private int date
private int time
private short year
private short month
private short day
private short hour
private short minute
private short second
private short millis
private boolean unpacked
private java.lang.String stringValue
String
.
private java.sql.Timestamp tsValue
java.sql.Timestamp
.
private java.sql.Date dateValue
java.sql.Date
.
private java.sql.Time timeValue
java.sql.Time
.
Constructor Detail |
DateTime(int date, int time)
date
- server date fieldtime
- server time fieldDateTime(short date, short time)
date
- server date fieldtime
- server time fieldDateTime(java.sql.Timestamp ts) throws java.sql.SQLException
java.sql.Timestamp
.
ts
- Timestamp
object representing the datetime
java.sql.SQLException
- if the date is out of rangeDateTime(java.sql.Time t) throws java.sql.SQLException
java.sql.Time
.
t
- Time
object representing the datetime
java.sql.SQLException
- if the time (date) is out of rangeDateTime(java.sql.Date d) throws java.sql.SQLException
java.sql.Date
.
d
- Date
object representing the datetime
java.sql.SQLException
- if the Date is out of rangeMethod Detail |
int getDate()
int
int getTime()
int
private void unpackDateTime()
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
public void packDate() throws java.sql.SQLException
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
java.sql.SQLException
- if the date is outside the accepted range, 1753-9999public void packTime()
public java.sql.Timestamp toTimestamp()
java.sql.Timestamp
public java.sql.Date toDate()
java.sql.Date
public java.sql.Time toTime()
java.sql.Time
public java.lang.Object toObject()
java.lang.Object
public java.lang.String toString()
String
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |