amPmMarker

abstract fun amPmMarker(am: String, pm: String)(source)

The AM/PM marker, using the specified strings.

am is used for the AM marker (0-11 hours), pm is used for the PM marker (12-23 hours).

Empty strings can not be used as markers. IllegalArgumentException is thrown if either am or pm is empty or if they are equal.

See also

Samples

import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   // Defining a custom format for the local time that uses AM/PM markers
val format = LocalTime.Format {
    amPmHour(); char(':'); minute(); char(':'); second()
    char(' '); amPmMarker("AM", "PM")
}
val formatted = format.format(LocalTime(9, 34, 58, 120_000_000))
check(formatted == "09:34:58 AM") 
   //sampleEnd
}