maropu commented on a change in pull request #23641: [SPARK-26719][SQL] Get rid 
of java.util.Calendar in DateTimeUtils
URL: https://github.com/apache/spark/pull/23641#discussion_r251000697
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeTestUtils.scala
 ##########
 @@ -46,4 +50,50 @@ object DateTimeTestUtils {
       TimeZone.setDefault(originalDefaultTimeZone)
     }
   }
+
+  def localDateTimeToMicros(localDateTime: LocalDateTime, tz: TimeZone): Long 
= {
+    val instant = localDateTime.atZone(tz.toZoneId).toInstant
+    DateTimeUtils.instantToMicros(instant)
+  }
+
+  // Returns microseconds since epoch for the given date
+  def date(
+      year: Int,
+      month: Byte = 1,
+      day: Byte = 1,
+      hour: Byte = 0,
+      minute: Byte = 0,
+      sec: Byte = 0,
+      micros: Int = 0,
+      tz: TimeZone = TimeZoneUTC): Long = {
+    val nanos = TimeUnit.MICROSECONDS.toNanos(micros).toInt
+    val localDateTime = LocalDateTime.of(year, month, day, hour, minute, sec, 
nanos)
+    localDateTimeToMicros(localDateTime, tz)
+  }
+
+  // Returns number of days since epoch for the given date
+  def days(
+     year: Int,
+     month: Byte = 1,
+     day: Byte = 1,
+     hour: Byte = 0,
+     minute: Byte = 0,
+     sec: Byte = 0): Int = {
 
 Review comment:
   nit: one more space

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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]

Reply via email to