Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
set correct TimeZone in test cases "to UTC timestamp" and "from UTC t…
…imestamp"
  • Loading branch information
ckadner committed Jun 20, 2016
commit 66254e0030451de43339753df12191776a0809a3
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,10 @@ class DateTimeUtilsSuite extends SparkFunSuite {

test("from UTC timestamp") {
def test(utc: String, tz: String, expected: String): Unit = {
assert(toJavaTimestamp(fromUTCTime(fromJavaTimestamp(Timestamp.valueOf(utc)), tz)).toString
=== expected)
DateTimeTestUtils.withDefaultTimeZone(TimeZone.getTimeZone("UTC")) {
assert(toJavaTimestamp(fromUTCTime(fromJavaTimestamp(Timestamp.valueOf(utc)), tz)).toString
=== expected)
}
}
test("2011-12-25 09:00:00.123456", "UTC", "2011-12-25 09:00:00.123456")
test("2011-12-25 09:00:00.123456", "JST", "2011-12-25 18:00:00.123456")
Expand All @@ -502,9 +504,11 @@ class DateTimeUtilsSuite extends SparkFunSuite {
}

test("to UTC timestamp") {
def test(utc: String, tz: String, expected: String): Unit = {
assert(toJavaTimestamp(toUTCTime(fromJavaTimestamp(Timestamp.valueOf(utc)), tz)).toString
=== expected)
def test(ts: String, tz: String, expected: String): Unit = {
DateTimeTestUtils.withDefaultTimeZone(TimeZone.getTimeZone(tz)) {
assert(toJavaTimestamp(toUTCTime(fromJavaTimestamp(Timestamp.valueOf(ts)), tz)).toString
=== expected)
}
}
test("2011-12-25 09:00:00.123456", "UTC", "2011-12-25 09:00:00.123456")
test("2011-12-25 18:00:00.123456", "JST", "2011-12-25 09:00:00.123456")
Expand Down