toLocalDateTime

fun Calendar.toLocalDateTime(): LocalDateTime

Convert Calendar to LocalDateTime.

Since

1.1.0


fun Date.toLocalDateTime(): LocalDateTime

Convert Date to LocalDateTime.

Since

1.1.0


fun LocalDate.toLocalDateTime(): LocalDateTime

Convert LocalDate to LocalDateTime.

Since

1.1.0


fun Long.toLocalDateTime(): LocalDateTime

Convert Long to LocalDateTime.

Example:

1659814200000.toLocalDateTime() // 2022-07-07T00:00

Since

1.1.0


fun String.toLocalDateTime(pattern: String = "EEE MMM dd HH:mm:ss zzz yyyy"): LocalDateTime

Produce a LocalDateTime from the given strings value and pattern.

Example:

"08/07/2022 13".toLocalDateTime("MM/dd/yyyy HH") // 2022-08-07T13:00
"Sun Aug 07 16:37:42 IRDT 2022".toLocalDateTime() // 2022-08-07T16:37:42
"7/2022".toLocalDateTime("MM/dd/yyyy") // ParseException

Since

1.1.0

Return

A LocalDateTime parsed from the string.

See also

Throws

if the beginning of the specified string cannot be parsed.

IllegalArgumentException

if the given pattern is invalid