date Time Components
An existing DateTimeFormat.
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() {
//sampleStart
// Using a predefined DateTimeComponents format in a larger format
val format = DateTimeComponents.Format {
char('{')
dateTimeComponents(DateTimeComponents.Formats.RFC_1123)
char('}')
}
val formatted = format.format {
setDateTimeOffset(
LocalDate(2021, 1, 13).atTime(9, 34, 58, 120_000_000),
UtcOffset(hours = 3, minutes = 30)
)
}
check(formatted == "{Wed, 13 Jan 2021 09:34:58 +0330}")
//sampleEnd
}