You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/03/20 05:17:58 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #27962: [SPARK-31195][SQL] Reuse days rebase functions of `DateTimeUtils` in `DaysWritable`

HyukjinKwon commented on a change in pull request #27962: [SPARK-31195][SQL] Reuse days rebase functions of `DateTimeUtils` in `DaysWritable`
URL: https://github.com/apache/spark/pull/27962#discussion_r395442753
 
 

 ##########
 File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/DaysWritable.scala
 ##########
 @@ -82,31 +80,15 @@ private[hive] object DaysWritable {
   // The code below converts -141714 to -141704.
   def rebaseGregorianToJulianDays(daysSinceEpoch: Int): Int = {
     if (daysSinceEpoch < DateTimeUtils.GREGORIAN_CUTOVER_DAY) {
-      val millis = Math.multiplyExact(daysSinceEpoch, DateTimeConstants.MILLIS_PER_DAY)
-      val utcCal = new Calendar.Builder()
-        .setCalendarType("gregory")
-        .setTimeZone(DateTimeUtils.TimeZoneUTC)
-        .setInstant(millis)
-        .build()
-      val localDate = LocalDate.of(
-        utcCal.get(Calendar.YEAR),
-        utcCal.get(Calendar.MONTH) + 1,
-        utcCal.get(Calendar.DAY_OF_MONTH))
-      Math.toIntExact(localDate.toEpochDay)
+      DateTimeUtils.rebaseGregorianToJulianDays(daysSinceEpoch)
 
 Review comment:
   Okay, this PR fixes a bug too, it had to be switched. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org