am Pm
The AM/PM state of the time component.
See also
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() {
//sampleStart
// Formatting and parsing a time with AM/PM marker in complex scenarios
val format = DateTimeComponents.Format {
amPmHour(); char(':'); minute(); char(':'); second(); char('.'); secondFraction(1, 9)
char(' '); amPmMarker("AM", "PM")
}
val formattedTime = format.format {
setTime(LocalTime(3, 46, 58, 123_456_789))
check(hour == 3)
check(minute == 46)
check(second == 58)
check(nanosecond == 123_456_789)
check(hourOfAmPm == 3)
check(amPm == AmPmMarker.AM)
}
check(formattedTime == "03:46:58.123456789 AM")
val parsedTime = format.parse("03:46:58.123456789 AM")
check(parsedTime.toLocalTime() == LocalTime(3, 46, 58, 123_456_789))
check(parsedTime.hour == null)
check(parsedTime.minute == 46)
check(parsedTime.second == 58)
check(parsedTime.nanosecond == 123_456_789)
check(parsedTime.hourOfAmPm == 3)
check(parsedTime.amPm == AmPmMarker.AM)
//sampleEnd
}