开发者

.NET: Local date format from language tag/culture?

开发者 https://www.devze.com 2023-01-10 06:56 出处:网络
Given a CultureInfo object or language tag (e.g. \"en-US\") string, is there a function that will give me the default DateTime string format (e.g. \"mm/dd/yyyy\") 开发者_Go百科for that specific cultur

Given a CultureInfo object or language tag (e.g. "en-US") string, is there a function that will give me the default DateTime string format (e.g. "mm/dd/yyyy") 开发者_Go百科for that specific culture/language?


For example:

// Display using pt-BR culture's short date format
// dd/MM/yyyy
CultureInfo culture = new CultureInfo("pt-BR");
Console.WriteLine(culture.DateTimeFormat.ShortDatePattern);

// Display using pt-BR culture's full date time pattern
// dddd, d' de 'MMMM' de 'yyyy HH:mm:ss´
Console.WriteLine(culture.DateTimeFormat.FullDateTimePattern);
0

精彩评论

暂无评论...
验证码 换一张
取 消