LuciferYang commented on code in PR #44613:
URL: https://github.com/apache/spark/pull/44613#discussion_r1443097993
##########
core/src/main/scala/org/apache/spark/ui/UIUtils.scala:
##########
@@ -42,15 +44,18 @@ private[spark] object UIUtils extends Logging {
val TABLE_CLASS_STRIPED = TABLE_CLASS_NOT_STRIPED + " table-striped"
val TABLE_CLASS_STRIPED_SORTABLE = TABLE_CLASS_STRIPED + " sortable"
- // SimpleDateFormat is not thread-safe. Don't expose it to avoid improper
use.
- private val dateFormat = new ThreadLocal[SimpleDateFormat]() {
- override def initialValue(): SimpleDateFormat =
- new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US)
- }
+ private val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd
HH:mm:ss", Locale.US)
Review Comment:
How about
```scala
private val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd
HH:mm:ss", Locale.US)
.withZone(java.time.ZoneId.systemDefault())
def formatDate(date: Date): String = dateTimeFormatter.format(date.toInstant)
def formatDate(timestamp: Long): String =
dateTimeFormatter.format(Instant.ofEpochMilli(timestamp))
```
--
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]