views:

130

answers:

2
?string.Format(CultureInfo.GetCultureInfo("en-US"), "{0:d}", now)
"4/12/2010"

?string.Format(CultureInfo.GetCultureInfo("fr-FR"), "{0:d}", now)
"12/04/2010"

I want to write a method: string GetDateFormat(culture)

?GetDateFormat(CultureInfo.GetCultureInfo("en-US"))
"M/d/yyyy"

?GetDateFormat(CultureInfo.GetCultureInfo("fr-FR"))
"dd/MM/yyyy"

Is it possible?

+3  A: 

You may take a look at the ShortDatePattern property:

CultureInfo.GetCultureInfo("en-US").DateTimeFormat.ShortDatePattern
Darin Dimitrov
+2  A: 

The more general purpose answer is to use GetAllDateTimePatterns:

CultureInfo.GetCultureInfo("en-US").DateTimeFormat.GetAllDateTimePatterns('d')[0]

Note that GetCultureInfo will not pick up any user overrides.

Eric MSFT
this was a way to resolve http://stackoverflow.com/questions/2621928/how-to-display-a-datetime-with-chosen-date-parts-but-in-the-order-of-the-formatp/2622391#2622391
serhio