Date format causing great problems in my app.

  • Thread starter Thread starter Jozef Jarosciak
  • Start date Start date
J

Jozef Jarosciak

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
 
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
 
This is a fix I found in vb.net and worked like a charm for me.


Dim ci As New System.Globalization.CultureInfo("en-US", False)
Dim newCi As System.Globalization.CultureInfo =
CType(ci.Clone(), System.Globalization.CultureInfo)
newCi.DateTimeFormat.AMDesignator = "AM"
newCi.DateTimeFormat.PMDesignator = "PM"
newCi.DateTimeFormat.ShortDatePattern = "M/d/yyyy"
Thread.CurrentThread.CurrentCulture = 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
 
Jozef Jarosciak said:
This is a fix I found in vb.net and worked like a charm for me.


Dim ci As New System.Globalization.CultureInfo("en-US",
False) Dim newCi As System.Globalization.CultureInfo =
CType(ci.Clone(), System.Globalization.CultureInfo)
newCi.DateTimeFormat.AMDesignator = "AM"
newCi.DateTimeFormat.PMDesignator = "PM"
newCi.DateTimeFormat.ShortDatePattern = "M/d/yyyy"
Thread.CurrentThread.CurrentCulture = 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

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

Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top