Formatting

The RadDateTimePicker gives you a few possibilities to change the way your data is formatted. This topic will go through the following sections:

Changing the display format

RadDateTimePicker has the ability to format its value in two different formats specified by the DisplayFormat property.

Here is a brief description of each value in the DisplayFormat enumerator property:

  • Short - this is the default value which will show you only the date and time formatted according to the current culture.

  • Long - this is the mode which shows a detailed information about the current date and time.

For example:

<telerik:RadDateTimePicker DisplayFormat="Long"/> 

Silverlight RadDateTimePicker Long DisplayFormat

Changing the culture

You can change the RadDateTimePicker control's culture via the Culture property. You can set its value in XAML or code behind. If you choose to set it in XAML you will have to provide the correct culture code. Otherwise in code behind you will have to create a CultureInfo object and assign it to the RadDateTimePicker's Culture property.

Here is an example:

<telerik:RadDateTimePicker x:Name="radDateTimePicker" Culture="de"/> 

this.radDateTimePicker.Culture = new System.Globalization.CultureInfo( "de" ); 
Me.radDateTimePicker.Culture = New System.Globalization.CultureInfo("de") 

Here is the result:

Silverlight RadDateTimePicker German Culture

Defining a custom format

You can easily customize the date format in the RadDateTimePicker through its Culture property. You do this by defining a custom DateFormatInfo object and later assigning it to the CultureInfo's DateTimeFormat property.

Here is an example of defining a custom format for the RadDateTimePicker's items:

this.radDateTimePicker.Culture = new System.Globalization.CultureInfo("en-US"); 
this.radDateTimePicker.Culture.DateTimeFormat.ShortDatePattern = "dd-MMM"; 
this.radDateTimePicker.Culture.DateTimeFormat.ShortTimePattern = "h tt"; 
Me.radDateTimePicker.Culture = New System.Globalization.CultureInfo("en-US") 
Me.radDateTimePicker.Culture.DateTimeFormat.ShortDatePattern = "dd-MMM" 
Me.radDateTimePicker.Culture.DateTimeFormat.ShortTimePattern = "h tt" 

In this example the "tt" in the ShortTimePattern represents the AM and PM values and also you have omitted the year from the ShortDatePattern's definition.

For more information about the custom date and time format specifiers and the result string produced by each format specifier, check out the Custom Date and Time Format Strings topic.

Here is the result:

Silverlight RadDateTimePicker Customized Culture Format

See Also

In this article