yaooqinn commented on pull request #2068:
URL:
https://github.com/apache/incubator-kyuubi/pull/2068#issuecomment-1062584708
How about?
```scala
class DateTimeFormatter {
private lazy val dateFormatter = {
createDateTimeFormatterBuilder().appendPattern("yyyy-MM-dd")
.toFormatter(Locale.US)
.withChronology(IsoChronology.INSTANCE)
}
private lazy val simpleDateFormatter = new SimpleDateFormat("yyyy-MM-dd",
Locale.US)
private lazy val timestampFormatter: DateTimeFormatter = {
createDateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm:ss")
.appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true)
.toFormatter(Locale.US)
.withChronology(IsoChronology.INSTANCE)
}
private lazy val simpleTimestampFormatter = {
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US)
}
private def createDateTimeFormatterBuilder(): DateTimeFormatterBuilder = {
new DateTimeFormatterBuilder().parseCaseInsensitive()
}
def formatDate(d: Date): String = {
simpleDateFormatter.format(d)
}
def formatLocalDate(d: LocalDate): String = {
dateFormatter.format(d)
}
def formatInstant(i: Instant): String = {
timestampFormatter.format(i)
}
def formatTimestamp(t: Timestamp): String = {
simpleTimestampFormatter.format(t)
}
```
--
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]