Date format not working for me

1 Answer 39 Views
DatePicker Grid
Martin Herløv
Top achievements
Rank 2
Bronze
Iron
Iron
Martin Herløv asked on 22 Dec 2021, 12:42 PM

Hi I am setting the culture in program.cs

var culture = new CultureInfo("da-DK");
culture.DateTimeFormat.ShortDatePattern = "dd-MM-yyyy";
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;

If I don't set it I get "dd.MM.yyyy"

I would like to set it to "dd/MM/yyyy" but when I do that it revert to "dd.MM.yyyy"

Is this me using the culture object in the wrong way or a bug in the Telerik Components?

1 Answer, 1 is accepted

Sort by
0
Joana
Telerik team
answered on 27 Dec 2021, 08:14 AM

Hello Martin,

The shared code snippet looks good and should work.

I prepared a Repl snippet based on your code and the DatePicker successfully shows the correct format:

https://blazorrepl.telerik.com/wlFQmgQE13htPVV954 

Perhaps, some configuration is missing in the Program.cs file, but it will be hard to predict what causes the issue. You could test the culture definition away from Telerik components through ToShortDateString method to verify whether the configuration is right. You might find useful the following resources:

https://github.com/pranavkm/LocSample 

https://docs.microsoft.com/en-us/aspnet/core/blazor/globalization-localization?view=aspnetcore-6.0

https://docs.telerik.com/blazor-ui/globalization/overview 

Regards,
Joana
Progress Telerik

Learn about the important changes coming in UI for Blazor 3.0 in January 2022!
Tags
DatePicker Grid
Asked by
Martin Herløv
Top achievements
Rank 2
Bronze
Iron
Iron
Answers by
Joana
Telerik team
Share this question
or