Skip to content

Date, Time, Timestamp Distinguishing String Formats. #33

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Date, Time, Timestamp Distinguishing String Formats. #33

wants to merge 1 commit into from

Conversation

danap
Copy link

@danap danap commented May 10, 2015

No description provided.

@xerial xerial self-assigned this May 11, 2015
@xerial
Copy link
Owner

xerial commented May 11, 2015

It looks like this change breaks existing method's behaviour: Please check the test failure: https://travis-ci.org/xerial/sqlite-jdbc/jobs/61998296

@danap
Copy link
Author

danap commented May 11, 2015

On Sun, May 10, 2015 11:30 pm, Taro L. Saito wrote:

It looks like this change breaks existing method's behaviour: Please
check the test failure:
https://travis-ci.org/xerial/sqlite-jdbc/jobs/61998296

Hello Taro,

I have reviewed the test failure and believe it may be corrected.

Before I proceed in that vein, wasting time, is it agreed that the
current implementation of sqlite-jdbc ResultSet.getDate() is returning
really a java.util.Date and not the definition of java.sql.Date. Notice
the setting of the latter, (def.), the time part being set to zero.

As I indicated the SQL standard defines a Date as (yyyy-MM-dd) with
no time context. This is not the same as DateTime, or Timestamp
which more formally coincides with java.util.Date.

Java API reference:

public class java.sql.Date
extends Date

A thin wrapper around a millisecond value that allows JDBC
to identify this as an SQL DATE value. A milliseconds value
represents the number of milliseconds that have passed since
January 1, 1970 00:00:00.000 GMT.

To conform with the definition of SQL DATE, the millisecond
values wrapped by a java.sql.Date instance must be 'normalized'
by setting the hours, minutes, seconds, and milliseconds to
zero in the particular time zone with which the instance is
associated.

@gotson
Copy link
Collaborator

gotson commented Jul 28, 2022

@danap is this PR still current ?

I was checking the original issue (#24) which is closed, though it looks like a more recent issue (#736).

@gotson gotson added the waiting for feedback Waiting for a feedback from the issue creator label Jul 29, 2022
public final static String DEFAULT_DATE_STRING_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
public final static String DEFAULT_DATE_STRING_FORMAT = "yyyy-MM-dd";
public final static String DEFAULT_TIME_STRING_FORMAT = "HH:mm:ss";
public final static String DEFAULT_TIMESTAMP_STRING_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not concat?

DATE_STRING_FORMAT("date_string_format", "Format to store and retrieve dates stored as text. Defaults to \"yyyy-MM-dd HH:mm:ss.SSS\"", null),
DATE_STRING_FORMAT("date_string_format", "Format to store and retrieve dates stored as text. Defaults to \"yyyy-MM-dd\"", null),
TIME_STRING_FORMAT("time_string_format", "Format to store and retrieve times stored as text. Defaults to \"HH:mm:ss\"", null),
TIMESTAMP_STRING_FORMAT("timestamp_string_format", "Format to store and retrieve timestamps stored as text. Defaults to \"yyyy-MM-dd HH:mm:ss.SSS\"", null),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..and reuse them here?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
waiting for feedback Waiting for a feedback from the issue creator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants