If you read the code, you'll see that "2006-01-02" is parsed
as a long integer - to 0L, actually, since it is not a valid 
integer. In your default time zone:

  Calendar.getInstance().setTimeInMillis(0) 

will produce a date of 1969-12-31 - a few hours earlier than the
UNIX epoch - because your time zone is west of the prime meridian, 
but east of the international date line. Ditto for null "date" 
values, they are also parsed as 0 milliseconds since the epoch.

Feel free to change your copy of the driver to fit your needs,
and share your changes with the list if you like.

--- jch <[EMAIL PROTECTED]> wrote:
> Thank for the information, I appreciate it.  However, I am not sure it
> explains what I am seeing.  The column I am calling the getDate method
> on has the value "2006-01-02" in it but it always returns "1969-12-31"
> in the Date object.  In addition, another column I call the getDate
> method on is Null but it doesn't return Null.  It returns "1969-12-31"
> as well.
> 
> Let me know if I missed something in your post.  Thanks.
> 
> 
> On Oct 22, 11:53 am, Joe Wilson <[EMAIL PROTECTED]> wrote:
> > --- jch <[EMAIL PROTECTED]> wrote:
> > > Are the getDate, getTime and getTimestamp JDBC methods supported?
> > > Whenever I use the getDate method it returns a value of "1969-12-31".
> > > In addition, one of my date columns is null and the getDate method
> > > still returns "1969-12-31" instead of null.  Am I doing something
> > > wrong?  I am using version 037.  Thanks.
> >
> > As sqlite3 does not have a date type, different sqlite wrapper authors
> > choose different conventions to represent dates. Some use strings, others
> > use julian days since year 0, others use milliseconds since the UNIX epoch
> > (Jan 1, 1970 00:00 GMT). sqlitejdbc uses the latter form for getDate
> > and getTimestamp.
> >
> > The jdbc driver source code is very straightforward. If you want a
> > different date convention, just change RS.java in your local copy:
> >
> >     public Date getDate(int col) throws SQLException {
> >         return new Date(db.column_long(pointer, markCol(col))); }
> >     public Date getDate(int col, Calendar cal) throws SQLException {
> >         if (cal == null) return getDate(col);
> >         cal.setTimeInMillis(db.column_long(pointer, markCol(col)));
> >         return new Date(cal.getTime().getTime());
> >     }
> >     public Date getDate(String col) throws SQLException {
> >         return getDate(findColumn(col), Calendar.getInstance()); }
> >     public Date getDate(String col, Calendar cal) throws SQLException {
> >         return getDate(findColumn(col), cal); }


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--~--~---------~--~----~------------~-------~--~----~
Mailing List: http://groups.google.com/group/sqlitejdbc?hl=en
To unsubscribe, send email to [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to