CultureInfo for Japanese language not setting up DateTimeFormat.AbbreviatedMonthNames property correctly

时光总嘲笑我的痴心妄想 提交于 2019-12-25 04:07:03

问题


I wanted to show the date in dd-MMM-yyyy format for Japanese culture in a web application. Hence I wrote below simple code.

CultureInfo cu = new CultureInfo("ja-JP");
System.Threading.Thread.CurrentThread.CurrentCulture = cu;
System.Threading.Thread.CurrentThread.CurrentUICulture = cu;
lbl1.Text = DateTime.Now.ToString("dd-MMM-yyyy");

But found that the label prints the month number instead of the month name. i.e. it shows 30-10-2014 instead of something 3 letter month name in japanese.

After debugging I came to know that the below property has month names in number instead of 3 letter month name.

> cu.DateTimeFormat.AbbreviatedMonthNames {string[13]}
>     [0]: "1"
>     [1]: "2"
>     [2]: "3"
>     [3]: "4"
>     [4]: "5"
>     [5]: "6"
>     [6]: "7"
>     [7]: "8"
>     [8]: "9"
>     [9]: "10"
>     [10]: "11"
>     [11]: "12"
>     [12]: ""

So is Japanese culture a special case or what I am trying to achieve is not possible. Note that if I change the culture to Chinese i.e. "zh-cn" I get correct chinese short month names.

来源:https://stackoverflow.com/questions/26650666/cultureinfo-for-japanese-language-not-setting-up-datetimeformat-abbreviatedmonth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!