如何将 ToLongDateString() 的日期和月份首字母大写导致 es-mx 文化? [英] how to uppercase date and month first letter of ToLongDateString() result in es-mx Culture?

查看:19
本文介绍了如何将 ToLongDateString() 的日期和月份首字母大写导致 es-mx 文化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我在 es-MX Culture 中从以下 C# 代码行获得以下结果

currently i obtain the below result from the following C# line of code when in es-MX Culture

   Thread.CurrentThread.CurrentCulture =
     Thread.CurrentThread.CurrentUICulture = new
                CultureInfo("es-mx");

  <span><%=DateTime.Now.ToLongDateString()%></span>

miércoles,2008 年 10 月 22 日

我想获得以下内容

miércoles, 22 de octubre de 2008

i would like to obtain the following

我需要建立自己的文化吗?

do i need to Build my own culture?

推荐答案

你不需要建立自己的文化.您只需要更改当前文化中的属性 DateTimeFormat.DayNames 和 DateTimeFormat.MonthNames.

You don't need to build your own culture. You only need to change the property DateTimeFormat.DayNames and DateTimeFormat.MonthNames in the current culture.

        string[] newNames = { "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado", "Domingo" };
        Thread.CurrentThread.CurrentCulture.DateTimeFormat.DayNames = newNames;

但是,奇怪的是 en-US 以第一个大写字母显示月份和日期,而 mx-ES 则没有.

However, it's weird that en-US show months and days with the first uppercase letter and for mx-ES not.

希望对你有帮助!

这篇关于如何将 ToLongDateString() 的日期和月份首字母大写导致 es-mx 文化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆