Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time Literal DateFormat Parsing #24

Closed
danap opened this issue Mar 22, 2015 · 5 comments
Closed

Time Literal DateFormat Parsing #24

danap opened this issue Mar 22, 2015 · 5 comments

Comments

@danap
Copy link

danap commented Mar 22, 2015

According to the jdbc4.0 ref. which I'm sure a new version is available, the following Date & Time
Literals have the format.

Date: {d, 'yyyy-mm-dd'}, Time:{t, 'hh:mm:ss'}, Timestamp: {ts, 'yyyy-mm-dd hh:mm:ss.f...'}

I would assume therefore if a TEXT data type field has the contents 2015-03-22 and contents are
returned via getDate() then I would not expect a date parse error would occur. Currently the
getDate() function is using a common DateFormat for all three of the time literals of
{yyyy-MM-dd HH:mm:ss.SSS}.

I would like to propose the SQLiteConfig class define the appropriate static instances of
DEFAULT_DATE_STRING_FORMAT, DEFAULT_TIME_STRING_FORMAT, & DEFAULT_TIMESTAMP_STRING_FORMAT along
with associated instances to be used in the resultSet returns for getDate(), getTime(), and
getTimeStamp(). It appears the setting methods are working appropriately.

If this is acceptable then I could perform the coding and submit for review and update. Perhaps
this issue is similar to open #18?

Thank you for your work in keeping the best option for the sqlite-jdbc current.

Dana Proctor
MyJSQLView Project Manager

@danap
Copy link
Author

danap commented Mar 23, 2015

Hello,

I have implemented the proposal indicated above and done the initial testing. The issue with date
parsing error is no longer occuring. No changes need be done for the setter methods except the
setDateByMilliseconds() method. The changes would define strict definitions to the Date & Time
Literal, as indicated above, with the exception for Timestamps being (yyyy-mm-dd hh:mm:ss).

I can submitt these changes for review if they seem an appropriate solution for date parsing
errors. My review of the initial code does not appear to have these issues because no DateFormat
aspects were applied.

Dana Proctor
MyJSQLView Project Manager

@danap
Copy link
Author

danap commented May 10, 2015

Hello,

I have created a Pull request #33 for review to address the issue indicated.

Dana Proctor
MyJQLView Project Manager

@TuomasKiviaho
Copy link

TuomasKiviaho commented Apr 19, 2016

There's also the JDBC3PreparedStatement involved in this when you use date_class=text. The setTime, and setDate do not work as expected as well as their counterparts plus setTimestamp with provided calendar.

@sirajka
Copy link

sirajka commented Feb 10, 2017

Is this related to the below exception? If not I can start a new issue.

Using current_timestamp in insert statement, SQLite stores it without milliseconds which causes the exception below on a subsequent read.

Caused by: java.text.ParseException: Unparseable date: "2017-02-10 01:03:29" does not match (\p{Nd}++)\Q-\E(\p{Nd}++)\Q-\E(\p{Nd}++)\Q \E(\p{Nd}++)\Q:\E(\p{Nd}++)\Q:\E(\p{Nd}++)\Q.\E(\p{Nd}++) at org.sqlite.date.FastDateParser.parse(FastDateParser.java:299) at org.sqlite.date.FastDateFormat.parse(FastDateFormat.java:490) at org.sqlite.jdbc3.JDBC3ResultSet.getTimestamp(JDBC3ResultSet.java:529)

@danap
Copy link
Author

danap commented Feb 10, 2017

Hello,

As far I know this issue has been addressed in other
changes implemented over a year ago. My proposed
pull was not accepted.

I would open another issued.

I thought I have requested this be close long ago.

danap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants