Date format causing great problems in my app.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jozef Jarosciak

    Date format causing great problems in my app.

    I have an application which imports fields from external source where
    date format of one the collumns is English (United States): M/d/yyyy.
    So July 1, 2005 equals to: 7/1/05
    I am using this date everywhere in the application.

    Problem is when someones is lets say in Portugal with the regional
    settings for date set to DD-MM-YYYY.

    I am going crazy to figure out how to make everyone to use M/d/yyyy
    scheme without changing their regional settings, as lots of people
    simply can't do that.

    Can someone point me to what I could do, or post some code on how to go
    around this annoying problem?

    It would be very much appreciated.

    Joe

  • Jozef Jarosciak

    #2
    Re: Date format causing great problems in my app.

    To add to this:
    I need some one liner, code which would set the whole program (form) to
    "M/d/yyyy" so whenever I do have to deal with date it would forget
    about my users DD-MM-YYYY format and assume they all have "M/d/yyyy".
    Is there any way to ignore regional settings and its date format?
    Joe

    Comment

    • Jozef Jarosciak

      #3
      Re: Date format causing great problems in my app.

      This is a fix I found in vb.net and worked like a charm for me.


      Dim ci As New System.Globaliz ation.CultureIn fo("en-US", False)
      Dim newCi As System.Globaliz ation.CultureIn fo =
      CType(ci.Clone( ), System.Globaliz ation.CultureIn fo)
      newCi.DateTimeF ormat.AMDesigna tor = "AM"
      newCi.DateTimeF ormat.PMDesigna tor = "PM"
      newCi.DateTimeF ormat.ShortDate Pattern = "M/d/yyyy"
      Thread.CurrentT hread.CurrentCu lture = newCi

      Just wanted to post it and share it with other. Now my whole
      application is switched to en-US format, no matter what country is my
      user from.
      Joe

      Comment

      • Armin Zingler

        #4
        Re: Date format causing great problems in my app.

        "Jozef Jarosciak" <joe@doprocess. com> schrieb[color=blue]
        > This is a fix I found in vb.net and worked like a charm for me.
        >
        >
        > Dim ci As New System.Globaliz ation.CultureIn fo("en-US",
        > False) Dim newCi As System.Globaliz ation.CultureIn fo =
        > CType(ci.Clone( ), System.Globaliz ation.CultureIn fo)
        > newCi.DateTimeF ormat.AMDesigna tor = "AM"
        > newCi.DateTimeF ormat.PMDesigna tor = "PM"
        > newCi.DateTimeF ormat.ShortDate Pattern = "M/d/yyyy"
        > Thread.CurrentT hread.CurrentCu lture = newCi
        >
        > Just wanted to post it and share it with other. Now my whole
        > application is switched to en-US format, no matter what country is
        > my user from.
        > Joe
        >[/color]

        Don't force the user to use a different date format they are used to. It is
        not necessary.

        Armin

        Comment

        Working...