DataFormDateEditor Date Format

4 posts, 1 answers
  1. Rodrigo
    Rodrigo avatar
    13 posts
    Member since:
    May 2018

    Posted 21 Oct Link to this post

    Hi,

    using com.telerik.widget.dataform.visualization.RadDataForm in Xamarin Native Android app.

    By Default, DataFormDateEditor has Date Format "MMM dd, YYYY" and First day of the week is Sunday.

    How can I change date format to dd.MM.YYYY and First Day of the week to Monday?

    Setting Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture seems not to have any effect...

    Regards,

    Rodrigo

  2. Answer
    Yana
    Admin
    Yana avatar
    5002 posts

    Posted 23 Oct Link to this post

    Hi Rodrigo,

    The date format of the DataFormDateEditor is defined per the application Locale and I am afraid we do not provide means to specify it.

    So, basically, you can change the application Locale, thus not taking into account the target device Locale.

    Setting the application Locale on Android is a little bit tricky, I have tested the following snippet inside OnCreate method of your MainActivity which works:

    var locale = new Java.Util.Locale("en", "GB"); // lang => en; region => GB
    Java.Util.Locale.Default = locale;
    var context = Application.Context;
    context.Resources.Configuration.Locale = locale;
    
    context.Resources.UpdateConfiguration(context.Resources.Configuration, context.Resources.DisplayMetrics);

    The problem is it uses deprecated API, here are some discussions on StackOverflow on the matter that can help:

    https://stackoverflow.com/questions/40221711/android-context-getresources-updateconfiguration-deprecated

    https://stackoverflow.com/questions/42535958/android-locale-and-updateconfiguration-are-deprecated

    Let me know if I can assist with anything else.

    Regards,
    Yana
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

  3. Rodrigo
    Rodrigo avatar
    13 posts
    Member since:
    May 2018

    Posted 27 Oct in reply to Yana Link to this post

    Thank you very much,

    that worked. Just a small note: if Android.App.Application.Context is used as per example - then Date Format is applied, but First day of the week stays Sunday. But if BaseContext is used then First Day of the week get set to Monday, as expected.

  4. Yana
    Admin
    Yana avatar
    5002 posts

    Posted 28 Oct Link to this post

    Hello Rodrigo,

    Thank you for sending that tip, it would be of much help to our users who also come across such a situation.

    Regards,
    Yana
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top