Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to set date time format as "MM/DD/YYYY" for the entire application (including referring dlls)

How to set date time format as "MM/DD/YYYY" for the entire application (including referring dlls)

Scheduled Pinned Locked Moved C#
tutorialquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    engsrini
    wrote on last edited by
    #1

    Hi I have tried the following code in Form's constructor Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); but it doesn't work in other dlls which are used by the applicaiton (form). How to achieve this? Thanks srini

    T P 2 Replies Last reply
    0
    • E engsrini

      Hi I have tried the following code in Form's constructor Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); but it doesn't work in other dlls which are used by the applicaiton (form). How to achieve this? Thanks srini

      T Offline
      T Offline
      Tim Paaschen
      wrote on last edited by
      #2

      I typically set the Application.CurrentCulture property in addition to the thread properties. Are you sure that the DLLs make use of the thread's culture settings? Maybe their localisation is hard-coded or they utilize the OS culture (CultureInfo.InstalledUICulture).

      Regards, Tim

      E 1 Reply Last reply
      0
      • T Tim Paaschen

        I typically set the Application.CurrentCulture property in addition to the thread properties. Are you sure that the DLLs make use of the thread's culture settings? Maybe their localisation is hard-coded or they utilize the OS culture (CultureInfo.InstalledUICulture).

        Regards, Tim

        E Offline
        E Offline
        engsrini
        wrote on last edited by
        #3

        Hi How can we make sure the dlls are using thread's culture settings? We just created dlls without touching any culture informations. But our OS is running on UK culture, thats why it is dispalying in DD/MM/YYYY format Actually in my application i have some calendar controls where it is displaying US format (after i made that culture change), but the data which i am getting from other dlls are in "DD/MM/YYYY" format! I thought changing the culture info of current thread will impact the referring dlls is it correct? Thanks srini

        1 Reply Last reply
        0
        • E engsrini

          Hi I have tried the following code in Form's constructor Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); but it doesn't work in other dlls which are used by the applicaiton (form). How to achieve this? Thanks srini

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          You should not force your culture on a client. The client's system settings should be used. If you must force a date/time format it should be ISO 8601.

          E 1 Reply Last reply
          0
          • P PIEBALDconsult

            You should not force your culture on a client. The client's system settings should be used. If you must force a date/time format it should be ISO 8601.

            E Offline
            E Offline
            engsrini
            wrote on last edited by
            #5

            no.... all our application is following US datetime format.. if somebody installed OS on UK culture.. then our application must send the datetime in US format irrelevant of system culture. Thats why we need to do this change.

            L 1 Reply Last reply
            0
            • E engsrini

              no.... all our application is following US datetime format.. if somebody installed OS on UK culture.. then our application must send the datetime in US format irrelevant of system culture. Thats why we need to do this change.

              L Offline
              L Offline
              lmoelleb
              wrote on last edited by
              #6

              Too bad - then your application has been developed by some pretty incompetent people. Your program should always use DateTime objects internally. If it needs to represent the date as a string, then do it using the ISO format mentioned. Preferably the internal format is UTC as well, unless there is an extremely good reason for it to be kept in local time. Various user interface controls (like your calender) should map to the users culture without problems (if it doesn't, ditch it and use something better). When interfacing the non-ISO system, encode to and from the specific format at the interface point - never let the bad format requiremen polute your internal program structure, and above all, never EVER let it polute the user interface.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups