-
Notifications
You must be signed in to change notification settings - Fork 627
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
Date, Time, Timestamp Distinguishing String Formats. #33
Open
danap
wants to merge
1
commit into
xerial:master
Choose a base branch
from
danap:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,11 +48,15 @@ public class SQLiteConfig | |
public final int busyTimeout; | ||
|
||
/* Date storage class*/ | ||
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"; | ||
public DateClass dateClass; | ||
public DatePrecision datePrecision; | ||
public long dateMultiplier; | ||
public String dateStringFormat; | ||
public String timeStringFormat; | ||
public String timestampStringFormat; | ||
|
||
/** | ||
* Default constructor. | ||
|
@@ -88,6 +92,8 @@ public SQLiteConfig(Properties prop) { | |
datePrecision = DatePrecision.getPrecision(pragmaTable.getProperty(Pragma.DATE_PRECISION.pragmaName, DatePrecision.MILLISECONDS.name())); | ||
dateMultiplier = (datePrecision == DatePrecision.MILLISECONDS) ? 1L : 1000L; | ||
dateStringFormat = pragmaTable.getProperty(Pragma.DATE_STRING_FORMAT.pragmaName, DEFAULT_DATE_STRING_FORMAT); | ||
timeStringFormat = pragmaTable.getProperty(Pragma.TIME_STRING_FORMAT.pragmaName, DEFAULT_TIME_STRING_FORMAT); | ||
timestampStringFormat = pragmaTable.getProperty(Pragma.TIMESTAMP_STRING_FORMAT.pragmaName, DEFAULT_TIMESTAMP_STRING_FORMAT); | ||
|
||
busyTimeout = Integer.parseInt(pragmaTable.getProperty(Pragma.BUSY_TIMEOUT.pragmaName, "3000")); | ||
} | ||
|
@@ -119,6 +125,8 @@ public void apply(Connection conn) throws SQLException { | |
pragmaParams.remove(Pragma.DATE_PRECISION.pragmaName); | ||
pragmaParams.remove(Pragma.DATE_CLASS.pragmaName); | ||
pragmaParams.remove(Pragma.DATE_STRING_FORMAT.pragmaName); | ||
pragmaParams.remove(Pragma.TIME_STRING_FORMAT.pragmaName); | ||
pragmaParams.remove(Pragma.TIMESTAMP_STRING_FORMAT.pragmaName); | ||
|
||
Statement stat = conn.createStatement(); | ||
try { | ||
|
@@ -213,6 +221,8 @@ public Properties toProperties() { | |
pragmaTable.setProperty(Pragma.DATE_CLASS.pragmaName, dateClass.getValue()); | ||
pragmaTable.setProperty(Pragma.DATE_PRECISION.pragmaName, datePrecision.getValue()); | ||
pragmaTable.setProperty(Pragma.DATE_STRING_FORMAT.pragmaName, dateStringFormat); | ||
pragmaTable.setProperty(Pragma.TIME_STRING_FORMAT.pragmaName, timeStringFormat); | ||
pragmaTable.setProperty(Pragma.TIMESTAMP_STRING_FORMAT.pragmaName, timestampStringFormat); | ||
|
||
return pragmaTable; | ||
} | ||
|
@@ -274,7 +284,9 @@ public static enum Pragma { | |
TRANSACTION_MODE("transaction_mode", toStringArray(TransactionMode.values())), | ||
DATE_PRECISION("date_precision", "\"seconds\": Read and store integer dates as seconds from the Unix Epoch (SQLite standard).\n\"milliseconds\": (DEFAULT) Read and store integer dates as milliseconds from the Unix Epoch (Java standard).", toStringArray(DatePrecision.values())), | ||
DATE_CLASS("date_class", "\"integer\": (Default) store dates as number of seconds or milliseconds from the Unix Epoch\n\"text\": store dates as a string of text\n\"real\": store dates as Julian Dates", toStringArray(DateClass.values())), | ||
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), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ..and reuse them here? |
||
BUSY_TIMEOUT("busy_timeout", null); | ||
|
||
public final String pragmaName; | ||
|
@@ -791,6 +803,20 @@ public void setDateClass(String dateClass) { | |
public void setDateStringFormat(String dateStringFormat) { | ||
this.dateStringFormat = dateStringFormat; | ||
} | ||
|
||
/** | ||
* @param timeStringFormat Format of time string | ||
*/ | ||
public void setTimeStringFormat(String timeStringFormat) { | ||
this.timeStringFormat = timeStringFormat; | ||
} | ||
|
||
/** | ||
* @param timestampStringFormat Format of timestamp string | ||
*/ | ||
public void setTimestampStringFormat(String timestampStringFormat) { | ||
this.timestampStringFormat = timestampStringFormat; | ||
} | ||
|
||
/** | ||
* @param milliseconds Connect to DB timeout in milliseconds | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not concat?