LuciferYang commented on code in PR #44616:
URL: https://github.com/apache/spark/pull/44616#discussion_r1454594178


##########
mllib/src/main/scala/org/apache/spark/mllib/pmml/export/PMMLModelExport.scala:
##########
@@ -34,7 +40,7 @@ private[mllib] trait PMMLModelExport {
     val version = getClass.getPackage.getImplementationVersion
     val app = new Application("Apache Spark MLlib").setVersion(version)
     val timestamp = new Timestamp()
-      .addContent(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", 
Locale.US).format(new Date()))
+      .addContent(DATE_TIME_FORMATTER.format(new Date().toInstant))

Review Comment:
   ditto



##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveTempPath.scala:
##########
@@ -41,6 +42,11 @@ class HiveTempPath(session: SparkSession, val hadoopConf: 
Configuration, path: P
 
   lazy val externalTempPath: Path = getExternalTmpPath(path)
 
+  private lazy val dateTimeFormatter =

Review Comment:
   This definition can also be moved to `object HiveTempPath`



##########
core/src/main/scala/org/apache/spark/deploy/worker/Worker.scala:
##########
@@ -821,7 +820,7 @@ private[deploy] class Worker(
   }
 
   private def generateWorkerId(): String = {
-    workerIdPattern.format(createDateFormat.format(new Date), host, port)
+    workerIdPattern.format(Worker.DATE_TIME_FORMATTER.format(new 
Date().toInstant), host, port)

Review Comment:
   Is it possible to directly use `Instant.now()` instead of `new 
Date().toInstant`?
   
   



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/continuous/ContinuousTextSocketSource.scala:
##########
@@ -185,8 +185,8 @@ class TextSocketContinuousStream(
             TextSocketContinuousStream.this.synchronized {
               currentOffset += 1
               val newData = (line,
-                Timestamp.valueOf(
-                  
TextSocketReader.DATE_FORMAT.format(Calendar.getInstance().getTime()))
+                Timestamp.valueOf(TextSocketReader.DATE_TIME_FORMATTER.format(
+                  Calendar.getInstance().getTime().toInstant))

Review Comment:
   Is it possible to directly use `Instant.now()` instead of new 
`alendar.getInstance().getTime().toInstant`?



##########
core/src/main/scala/org/apache/spark/rdd/NewHadoopRDD.scala:
##########
@@ -104,8 +105,11 @@ class NewHadoopRDD[K, V](
   // private val serializableConf = new SerializableWritable(_conf)
 
   private val jobTrackerId: String = {
-    val formatter = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US)
-    formatter.format(new Date())
+    val dateTimeFormatter =
+      DateTimeFormatter
+        .ofPattern("yyyyMMddHHmmss", Locale.US)
+        .withZone(ZoneId.systemDefault())
+    dateTimeFormatter.format(new Date().toInstant)

Review Comment:
   ditto



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to