Martin Spedding's Blog

Adventures in a disconnected world

Turning 40 and converting from one date format to another

Well the 10th of July was the big day. I am now no longer a 30 something. I have to be honest I felt a bit depressed it is just another day and another number but I liked being in my 30's and 40's is starting to sound old. It is funny if we wanted to migrate to Australia that it would have been no problem whilst I was 39 but now that I am 40 it would be much more difficult.

Those few job adverts you see in the newspapers all say only apply if you are under 40. Luckly my job seems to be reasonably safe.

Being 40 also means I almost been working 50% of my life as I left University at the age of 21. I have seen mainframes, mini computers, pcs and the internet all becoming important platforms. I wonder if the next 20 years will be as exciting as the last 20.

I thought I better add some .Net content to this blog entry:

How to convert a date, that is formatted according to the locale of the machine, to a standard format:

uses System.Globalization

Public String DateToString(DateTime 
   dt, String LangCode) {

   CultureInfo ci = new 
      CultureInfo(LangCode);

   return dt.ToString(ci);
}
I did not write the function but found it here http://www.fawcette.com/archives/premier/mgznarch/vbpj/2001/10oct01/qa0110/qa0110.asp
It was so useful when I found that some of the users of my application were using German format dates and one was using American format.
Also if you are writing software that needs to be used in different countries and you are starting to use the System.Globalization namespace this table of locale information will help alot.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsmscLCID.asp
Have fun
 
 

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)