则DateTime.ToString月,天语 [英] datetime.tostring month and day language

查看:156
本文介绍了则DateTime.ToString月,天语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有有不同国籍的(每个人我有ISO代码)的人的电子邮件地址列表

i have a list of email addresses of people that have different nationalities (for each person i have the iso code)

当我发送电子邮件至所有这些人在邮件的正文我需要为datetime字段转换为在其特定的文化格式化字符串。

when i send the email to all these people, in the text of the mail i need to to convert a datetime field to a string formatted in their specific culture.

为了这个,我正在做

CultureInfo ci = new CultureInfo(ISO);
myStringDate = myDate.ToString(ci.DateTimeFormat.ShortDatePattern);

和工作完美,但如果我使用LongDatePattern代替短,像「MONDAY显示日期6月13日2010它的做工精细,除了日和月的语言。

and work perfect, but if i use LongDatePattern instead short, for displaying date like "Monday, 13 June 2010" its work fine except the language of the day and month.

如果这个人的文化是它-IT我需要显示Martedi和朱尼奥不星期一和六一

if the person culture is it-IT i need to display "Martedi" and "Giugno" not "monday" and "June"

我怎么能做到这一点不改变当前的UI文化?

how can i do that without change the current UI culture?

推荐答案

这些模式描述了年,月,日和其他参数的在日期时间的输出结果的位置即可。但是,月,日的名称从CultureInfo对象,而不是采取格局。有则DateTime.ToString超载支持传入的CultureInfo参数与格式一起

Those patterns describe year, month, day and other parameter locations in output result of Datetime. But month and day names are taken from CultureInfo object, not pattern. There's DateTime.ToString overload that supports passing CultureInfo parameter along with format

        CultureInfo culture = new CultureInfo(ISO); 
        DateTime.Now.ToString(culture.DateTimeFormat.LongDatePattern, culture);



这样,toString()方法会从指定的区域性

This way, ToString() will respect both pattern and names from specified culture

这篇关于则DateTime.ToString月,天语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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