{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

DatePickerFormatter

@ExperimentalMaterial3Api
public interface DatePickerFormatter


A date formatter interface used by DatePicker.

Summary

Public methods

abstract String
formatDate(
    Long dateMillis,
    @NonNull CalendarLocale locale,
    boolean forContentDescription
)

Format a given dateMillis to a string representation of the date (i.e. Mar 27, 2021).

abstract String
formatMonthYear(Long monthMillis, @NonNull CalendarLocale locale)

Format a given monthMillis to a string representation of the month and the year (i.e. January 2023).

Public methods

formatDate

abstract String formatDate(
    Long dateMillis,
    @NonNull CalendarLocale locale,
    boolean forContentDescription
)

Format a given dateMillis to a string representation of the date (i.e. Mar 27, 2021).

Parameters
Long dateMillis

timestamp in UTC milliseconds from the epoch that represents the date

@NonNull CalendarLocale locale

a CalendarLocale to use when formatting the date

boolean forContentDescription

indicates that the requested formatting is for content description. In these cases, the output may include a more descriptive wording that will be passed to a screen readers.

See also
defaultLocale

formatMonthYear

abstract String formatMonthYear(Long monthMillis, @NonNull CalendarLocale locale)

Format a given monthMillis to a string representation of the month and the year (i.e. January 2023).

Parameters
Long monthMillis

timestamp in UTC milliseconds from the epoch that represents the month

@NonNull CalendarLocale locale

a CalendarLocale to use when formatting the month and year

See also
defaultLocale