toDate

Convert Calendar to Date.

Since

1.1.0


fun Long.toDate(): Date

Convert Long to Date.

Example:

1659873010453L.toDate() // Sun Aug 07 16:20:10 IRDT 2022

Since

1.1.0


fun Duration.toDate(): Date

Convert Duration to Date.

Example:

1.days.toDate() // Fri Jan 02 03:30:00 IRST 1970

Since

1.1.0


@JvmOverloads
fun String.toDate(pattern: String = "EEE MMM dd HH:mm:ss zzz yyyy"): Date

Produce a date from the given strings value and pattern.

Example:

"8/7/2022".toDate("MM/dd/yyyy") // Sun Aug 07 00:00:00 IRDT 2022
"Sun Aug 07 16:37:42 IRDT 2022".toDate() // Sun Aug 07 16:37:42 IRDT 2022
"7/2022".toDate("MM/dd/yyyy") // ParseException

Since

1.1.0

Return

A Date parsed from the string.

See also

Throws

if the beginning of the specified string cannot be parsed.

IllegalArgumentException

if the given pattern is invalid


fun Instant.toDate(): Date

Convert Instant to Date.

Since

1.1.0


fun LocalDate.toDate(): Date

Convert LocalDate to Date.

Since

1.1.0


fun LocalDateTime.toDate(): Date

Convert LocalDateTime to Date.

Since

1.1.0


fun LocalTime.toDate(): Date

Convert LocalTime to Date.

Since

1.1.0