Reputation: 32926
WHen using the CultureInfo to render a number, #,000.00 does not literally mean place a , for the thousands separator and a . for the decimal. It means use the correct character from that culture at those locations.
However, using "mm-dd-yyyy" places the month, day, year in that order regardless of culture. Is there a way to tell it I'm passing the US format but change to match the passed in culture?
More details:
CultureInfo ci = new System.Globalization.CultureInfo("de-DE");
DateTime birthday = new DateTime(1955, 9, 26);
string displayValue = BIRTHDAY.tOsTRING("M/d/yyyy", ci);
Upvotes: 0
Views: 173
Reputation: 100537
Use DateTimeFormatInfo.ShortDatePattern instead of hard coded string.
var text = date1.ToString(CultureInfo.CreateSpecificCulture("fr-FR")
.DateTimeFormat.ShortDatePattern);
Upvotes: 2