TimePickerState

class TimePickerState(initialHour: Int, initialMinute: Int, initialPeriod: TimePeriod, val timeFormat: TimeFormat)

State holder for the TimePicker.

Manages the state of the hour, minute, and period (AM/PM) pickers. Internal picker states are not directly accessible to prevent inconsistent state modifications.

Parameters

initialHour

The initial hour to be selected.

initialMinute

The initial minute to be selected.

initialPeriod

The initial period (AM/PM) to be selected.

timeFormat

The time format (12-hour or 24-hour).

Constructors

Link copied to clipboard
constructor(initialHour: Int, initialMinute: Int, initialPeriod: TimePeriod, timeFormat: TimeFormat)
constructor(initialTime: LocalTime, timeFormat: TimeFormat = TimeFormat.HOUR_24)

Creates a TimePickerState from a LocalTime.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The currently selected hour. For 12-hour format: 1-12, for 24-hour format: 0-23.

Link copied to clipboard

The selected hour converted to 24-hour clock time (0-23).

Link copied to clipboard

The currently selected minute (0-59).

Link copied to clipboard

The currently selected period (AM/PM). Only relevant when using 12-hour format.

Link copied to clipboard
val selectedTime: LocalTime

The selected time represented as LocalTime.

Link copied to clipboard

Functions

Link copied to clipboard
fun selectTime(time: LocalTime)

Programmatically selects time.

fun selectTime(hour: Int, minute: Int)

Programmatically selects a time from 24-hour clock parts.

fun selectTime(time: LocalTime, items: TimePickerItems)

Programmatically selects the closest time to time that is allowed by items.

fun selectTime(hour: Int, minute: Int, items: TimePickerItems)

Programmatically selects the closest time to hour and minute that is allowed by items.

fun selectTime(displayHour: Int, minute: Int, period: TimePeriod)

Programmatically selects a time from a 12-hour display value.

fun selectTime(displayHour: Int, minute: Int, period: TimePeriod, items: TimePickerItems)

Programmatically selects the closest time to a 12-hour display value allowed by items.