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

Remove usages of deprecated parseTimestampInLocalTime #11041

Merged
merged 2 commits into from
Jul 18, 2018
Merged

Remove usages of deprecated parseTimestampInLocalTime #11041

merged 2 commits into from
Jul 18, 2018

Conversation

findepi
Copy link
Contributor

@findepi findepi commented Jul 13, 2018

No description provided.

@@ -179,13 +180,13 @@ public void testAllDataTypes()
.containsOnly(
row("\0", Long.MIN_VALUE, Bytes.fromHexString("0x00").array(), false, 0f, Double.MIN_VALUE,
Float.MIN_VALUE, "[0]", "0.0.0.0", Integer.MIN_VALUE, "[0]", "{\"\\u0000\":-2147483648,\"a\":0}",
"[0]", "\0", parseTimestampInLocalTime("1970-01-01 00:00:00.0", PRODUCT_TESTS_TIME_ZONE),
Copy link
Contributor

@sopel39 sopel39 Jul 16, 2018

Choose a reason for hiding this comment

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

so the PRODUCT_TESTS_TIME_ZONE was completely ignored here?

parseMillis javadoc:

     * Parses a datetime from the given text, returning the number of
     * milliseconds since the epoch, 1970-01-01T00:00:00Z.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it wasn't. It had to match JVM time zone though (because of how java.sql.Timestamp internal repr works), and now this is done automatically via Timestamp.valueOf(LocalDateTime)

Copy link
Contributor

Choose a reason for hiding this comment

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

No, it wasn't. It had to match JVM time zone though (because of how java.sql.Timestamp internal repr works)

Looking at the:

    public static Timestamp parseTimestampInLocalTime(String value, DateTimeZone timeZone)
    {
        return new Timestamp(DATE_TIME_FORMATTER.withZone(timeZone).parseMillis(value));
    }

it used parseMillis(value). And parseMillis(value) should be independent of timeZone parameter, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Specifically parseMillis states:

     * The parse will use the ISO chronology, and the default time zone.
     * If the text contains a time zone string then that will be taken into account.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the result of DATE_TIME_FORMATTER.withZone(timeZone).parseMillis(value) depends on timeZone when value doesn't specify time zone.

@findepi findepi merged commit 3e2191c into prestodb:master Jul 18, 2018
@findepi findepi deleted the findepi/remove-usage-of-parseTimestampInLocalTime branch July 18, 2018 06:14
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

Successfully merging this pull request may close these issues.

3 participants