kejpa Posted June 11, 2004 Posted June 11, 2004 Hi, In my application I want to make sure that all dateformats are like "2004-06-11" no matter what the user has set in his regional settings. I thought it would be easy just.... Application.CurrentCulture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd" but oh, no! This property is read-only. And creating a new one Dim ciMe As System.Globalization.CultureInfo = System.Globalization.CultureInfo.InvariantCulture() ciMe.DateTimeFormat = New System.Globalization.DateTimeFormatInfo() ciMe.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd" won't work either. Please help me out. /Kejpa Quote
*Experts* DiverDan Posted June 12, 2004 *Experts* Posted June 12, 2004 (edited) I had to do a similar thing with the decimal seperator. As an example, here's my solution, also the only way I found this to work. InformationBox() is a custom dialog MessageBox. Private Sub Check_DecimalSeparator() Dim separatorFormat As New System.Globalization.NumberFormatInfo() If separatorFormat.CurrentInfo.NumberDecimalSeparator = "," Then Dim frmInformationBox As New InformationBox() frmInformationBox.Captions("Comma Decimal Seperator Format", "Volts currently supports and displays a dot(.) as a decimal separator.", "Information", "Okay") frmInformationBox.ShowDialog() Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US") separatorFormat.NumberDecimalSeparator = "." End If End Sub This snippet shows how to check and override the users Regional settings. You will need to check Window's Regional settings to get the date format you want. Also, changing the format as I did is only temporary and will not affect the users settings once your program is exited. I also had to set date formats in Volts, but chose to do it as a user defined setting... One for the USA standard. One for the rest of the World's standard. And one for military standard - always gotta be different here, sorta like "there's always one in every crowd" different! Now for the commentary ... Why does the USA have to have the decimal seperator and date format completely different from the rest of the World? It makes a lot of sense to use a comma instead of a dot for a decimal seperator as most of the SI world has currently adapted. The date format is so trival that I wish that someone will adapt one of the two formats as standard (forget the military, they won't listen to anything that makes common sense anyway). Then multi-national programmers could spend their time doing stuff that's really important compared to silly date and decimal seperator formats. End of commentary ... :rolleyes: Dan Edited June 12, 2004 by DiverDan Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
pelikan Posted June 13, 2004 Posted June 13, 2004 OK Dan. Should we all wear red pants and sport green hats with feathers too? Quote IN PARVUM MULTUM
*Experts* DiverDan Posted June 13, 2004 *Experts* Posted June 13, 2004 I love it! Brilliant! All kinding aside, math, date formats included, should be universal with set standards. Even the USA has adapted SI units in science and engineering. Metrics are soon to follow. Everyone is an individual and should express themselves as individuals, but this stuff is math, science and engineering. Dan Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
kejpa Posted June 14, 2004 Author Posted June 14, 2004 Thanx Diverdan, I've gotten it to work, and for your comment on standards .... "Standards are great, everyone should have his." SeaU /Kejpa Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.