-
-
Notifications
You must be signed in to change notification settings - Fork 139
[WIP] Removes JodaTime #157
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cbdd227
Removes all jodatime references in the common library, cleans up
bakatz 4f667ab
Removes jodatime references from the mysql driver
bakatz 2cfe6d0
Reverts build.gradle change
bakatz 4669abe
Removes commented code
bakatz 3d49bc4
Fixes millis conversion
bakatz 9e7abec
Fixes more ns calculations
bakatz 9315653
Fixes TimestampEncoderDecoder to use ZonedDateTime to allow for the '…
bakatz 84e583a
Corrects milliseconds value in test
bakatz 0fab137
~temp logging to try to debug why the test is failing
bakatz e43ac6c
~changes test log level to info to avoid log spam
bakatz 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 hidden or 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 hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
db-async-common/src/main/java/com/github/jasync/sql/db/RowData.kt
This file contains hidden or 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
14 changes: 7 additions & 7 deletions
14
db-async-common/src/main/java/com/github/jasync/sql/db/column/DateEncoderDecoder.kt
This file contains hidden or 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
10 changes: 1 addition & 9 deletions
10
db-async-common/src/main/java/com/github/jasync/sql/db/column/InetAddressEncoderDecoder.kt
This file contains hidden or 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
11 changes: 5 additions & 6 deletions
11
db-async-common/src/main/java/com/github/jasync/sql/db/column/LocalDateTimeEncoderDecoder.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,28 +1,27 @@ | ||
| package com.github.jasync.sql.db.column | ||
|
|
||
| import org.joda.time.LocalDateTime | ||
| import org.joda.time.format.DateTimeFormatterBuilder | ||
| import java.time.LocalDateTime | ||
| import java.time.format.DateTimeFormatterBuilder | ||
|
|
||
| object LocalDateTimeEncoderDecoder : ColumnEncoderDecoder { | ||
|
|
||
| private const val ZeroedTimestamp = "0000-00-00 00:00:00" | ||
|
|
||
| private val optional = DateTimeFormatterBuilder() | ||
| .appendPattern(".SSSSSS").toParser() | ||
| .appendPattern(".SSSSSS").toFormatter() | ||
|
|
||
| private val format = DateTimeFormatterBuilder() | ||
| .appendPattern("yyyy-MM-dd HH:mm:ss") | ||
| .appendOptional(optional) | ||
| .toFormatter() | ||
|
|
||
| override fun encode(value: Any): String = | ||
| format.print(value as LocalDateTime) | ||
| override fun encode(value: Any): String = (value as LocalDateTime).format(format) | ||
|
|
||
| override fun decode(value: String): LocalDateTime? = | ||
| if (ZeroedTimestamp == value) { | ||
| null | ||
| } else { | ||
| format.parseLocalDateTime(value) | ||
| LocalDateTime.parse(value, format) | ||
| } | ||
|
|
||
| } |
10 changes: 3 additions & 7 deletions
10
db-async-common/src/main/java/com/github/jasync/sql/db/column/SQLTimeEncoder.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,17 +1,13 @@ | ||
| package com.github.jasync.sql.db.column | ||
|
|
||
| import org.joda.time.LocalTime | ||
| import org.joda.time.format.DateTimeFormatterBuilder | ||
| import java.time.LocalTime | ||
| import java.time.format.DateTimeFormatterBuilder | ||
|
|
||
| object SQLTimeEncoder : ColumnEncoder { | ||
|
|
||
| private val format = DateTimeFormatterBuilder() | ||
| .appendPattern("HH:mm:ss") | ||
| .toFormatter() | ||
|
|
||
| override fun encode(value: Any): String { | ||
| val time = value as java.sql.Time | ||
|
|
||
| return format.print(LocalTime(time.time)) | ||
| } | ||
| override fun encode(value: Any): String = (value as java.sql.Time).toLocalTime().format(format) | ||
| } |
This file contains hidden or 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
5 changes: 2 additions & 3 deletions
5
...nc-common/src/main/java/com/github/jasync/sql/db/column/TimeWithTimezoneEncoderDecoder.kt
This file contains hidden or 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 hidden or 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
8 changes: 4 additions & 4 deletions
8
...mmon/src/main/java/com/github/jasync/sql/db/column/TimestampWithTimezoneEncoderDecoder.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| package com.github.jasync.sql.db.column | ||
|
|
||
| import org.joda.time.format.DateTimeFormat | ||
| import org.joda.time.format.DateTimeFormatter | ||
| import java.time.ZonedDateTime | ||
| import java.time.format.DateTimeFormatter | ||
|
|
||
| object TimestampWithTimezoneEncoderDecoder : TimestampEncoderDecoder() { | ||
|
|
||
| private val format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSSSSSZ") | ||
| private val format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSZ") | ||
|
|
||
| override fun formatter(): DateTimeFormatter = format | ||
|
|
||
| override fun decode(value: String): Any { | ||
| return formatter().parseDateTime(value) | ||
| return ZonedDateTime.parse(value, formatter()) | ||
| } | ||
|
|
||
| } |
2 changes: 1 addition & 1 deletion
2
db-async-common/src/test/java/com/github/jasync/sql/db/RowDataTest.kt
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
This was not compiling for me using JDK 11 (AdoptOpenJDK, windows), and generally using sun.* packages is discouraged - decided to replace with standard java library calls. Let me know if there's a reason this textToNumeric() call was made in the first place - seems like .getByName() works OK
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.
I think I checked it and this method not exists in java 8
Uh oh!
There was an error while loading. Please reload this page.
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.
Yep, the textToNumeric methods aren't public/don't exist or something. That's why I decided to remove them.