Skip to content

DateTimeFormatter equivalent #211

Closed
Closed
@ArcherEmiya05

Description

@ArcherEmiya05

It is not included in the documentation so we would like to ask if Kotlinx Datetime has java.time.format.DateTimeFormatter equivalent for formatting?

Here are the following usage we had with the Java DateTimeFormatter

val formattedDate: String
        get() = LocalDate.parse(date, DateTimeFormatter.ISO_LOCAL_DATE_TIME).format(
            DateTimeFormatter.ofPattern("MMM. dd, yyyy")
        )
  val formattedTime: String = Instant.ofEpochMilli(time).atZone(ZoneId.systemDefault())
  .toLocalDate().format(DateTimeFormatter.ofPattern("MM-dd-yyyy"))
LocalDateTime.parse(
                  lowDate,
                  DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
              )

Currently using coreLibraryDesugaringEnabled for backward compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    formattersRelated to parsing and formatting

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions