MaxGekk commented on a change in pull request #27494: [WIP] Port `millisToDays`
and `daysToMillis` on Java 8 time API
URL: https://github.com/apache/spark/pull/27494#discussion_r376733305
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala
##########
@@ -86,9 +86,13 @@ class DateTimeUtilsSuite extends SparkFunSuite with
Matchers with SQLHelper {
}
test("SPARK-6785: java date conversion before and after epoch") {
+ def format(d: Date): String = {
+ TimestampFormatter("uuuu-MM-dd", defaultTimeZone().toZoneId)
+ .format(d.getTime * MICROS_PER_MILLIS)
+ }
def checkFromToJavaDate(d1: Date): Unit = {
val d2 = toJavaDate(fromJavaDate(d1))
- assert(d2.toString === d1.toString)
+ assert(format(d2) === format(d1))
Review comment:
I had to use the formatter to avoid calendar problems - `Date.toString`
formats slightly differently than `DateTimeFormatter`, I guess because of
different year lengths in calendars.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]