Github user sergey-rubtsov commented on a diff in the pull request: https://github.com/apache/spark/pull/21363#discussion_r189583203 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParserSuite.scala --- @@ -107,20 +107,26 @@ class UnivocityParserSuite extends SparkFunSuite { assert(parser.makeConverter("_1", BooleanType, options = options).apply("true") == true) val timestampsOptions = - new CSVOptions(Map("timestampFormat" -> "dd/MM/yyyy hh:mm"), "GMT") + new CSVOptions(Map("timestampFormat" -> "dd/MM/yyyy HH:mm"), "GMT") val customTimestamp = "31/01/2015 00:00" - val expectedTime = timestampsOptions.timestampFormat.parse(customTimestamp).getTime + + val expectedTime = LocalDateTime.parse(customTimestamp, timestampsOptions.timestampFormatter) + .atZone(options.timeZone.toZoneId) + .toInstant.toEpochMilli val castedTimestamp = - parser.makeConverter("_1", TimestampType, nullable = true, options = timestampsOptions) + parser.makeConverter("_1", TimestampType, nullable = true, timestampsOptions) .apply(customTimestamp) assert(castedTimestamp == expectedTime * 1000L) - val customDate = "31/01/2015" val dateOptions = new CSVOptions(Map("dateFormat" -> "dd/MM/yyyy"), "GMT") - val expectedDate = dateOptions.dateFormat.parse(customDate).getTime + val customDate = "31/01/2015" + + val expectedDate = LocalDate.parse(customDate, dateOptions.dateFormatter) + .atStartOfDay(options.timeZone.toZoneId) + .toInstant.toEpochMilli val castedDate = - parser.makeConverter("_1", DateType, nullable = true, options = dateOptions) --- End diff -- ok
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org