gpt4 book ai didi

c# - 更改日期选择器文本 : capitalize month

转载 作者:太空狗 更新时间:2023-10-29 23:01:14 26 4
gpt4 key购买 nike

我想通过大写月份的第一个字母来更改日期选择器。

目前我在线程中使用设置文化信息并在那里指定格式,但对于我的文化,月份总是全部小写:

CultureInfo ci = new CultureInfo("es-MX");
ci.DateTimeFormat.ShortDatePattern = "ddd dd/MMM/yyyy";
Thread.CurrentThread.CurrentCulture = ci;

显示:

Dom 19/ago/2012

我想要:

Dom 19/Ago/2012

我怎样才能改变它?

最佳答案

指定 AbbreviatedMonthGenitiveNamesAbbreviatedMonthNames 以及 ShortDatePattern 就可以了。

Thread.CurrentThread.CurrentCulture = new CultureInfo("es-MX")
{
DateTimeFormat = new DateTimeFormatInfo
{
AbbreviatedMonthGenitiveNames = new string[] { "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic", string.Empty },
AbbreviatedMonthNames = new string[] { "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic", string.Empty },
ShortDatePattern = "ddd dd/MMM/yyyy"
}
};

产量:

enter image description here

编辑:

我必须补充:

...
AbbreviatedDayNames = new string[] { "Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"},

也是

关于c# - 更改日期选择器文本 : capitalize month,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12028275/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com