date

fun date(pattern: String, locale: Locale = Locale.getDefault(), zone: ZoneId = ZoneId.systemDefault(), nullText: String = ""): (Any?) -> String(source)

Formats a date or time with a DateTimeFormatter pattern.

Handles java.time values, a legacy java.util.Date, and a Long read as epoch milliseconds. A pattern the value cannot satisfy — HH:mm against a LocalDate — falls back to the value's own toString() rather than throwing.

Parameters

pattern

A DateTimeFormatter pattern, such as dd MMM yyyy or yyyy-MM-dd HH:mm.

locale

Decides month and day names.

zone

Zone used to give an instant a wall-clock date and time. Ignored by values that already carry their own date, such as LocalDate.

nullText

What a null value renders as.