TimeSpan Formatting

TimeSpanPicker for .NET MAUI allows you to use standard or custom time format strings. Set formatting to the spinners that are displayed when the picker is opened - through the SpinnerFormat property and when time is selected through the DisplayStringFormat property.

DisplayString Format

  • DisplayStringFormat(string): Defines the format of the string that will be visualized when the picker dialog is closed.

The format set for DisplayStringFormat should be a valid time span format - Standard Time Formst Strings and Custom Time format Strings.

Spinner Format

TimeSpan Picker for Xamarin allows you to use standard or custom timespan format strings through the SpinnerFormat property. Depending on what format is set, the picker visualizes spinner controls with prepopulated values to be picked.

  • SpinnerFormat(string): Defines the string format for the spinners. The default format is "g".

Standard TimeSpan Format Strings

The available Standard TimeSpan Format Strings which can be set to the SpinnerFormat property are described in the table below:

Supported Standard TimeSpan Format String Description
"G" General Long "G" format specifier
"g" General Short "g" format specifier
"c" Constant "c" format specifier

You can set only short Standard TimeSpan Format Strings to the TimeSpan Picker control.

Custom TimeSpan Format Strings

The available Custom TimeSpan Format Strings which can be set to the SpiinerFormat property are described in the table below:

Supported Custom TimeSpan Format Strings
"d"
"dd"
"ddd"
"dddd"
"h"
"hh"
"m"
"mm"
"s"
"ss"

You can set only short Custom TimeSpan Format Strings to the TimeSpan Picker control.

Supported Separators

When SpinnerFormat is set and device culture is changed, the separators used for the format string won't be changed:

Supported Separator Formats
"-"
"."
","
" "
":"
"/"

See Also

In this article
Not finding the help you need?