选择正确的DateTimePattern [英] Picking the right DateTimePattern

查看:395
本文介绍了选择正确的DateTimePattern的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的当前设置显示这样的日期时间(en-GB):

My current setting displays a DateTime like this (en-GB):

DateTime DT = DateTime.Now.ToString(" F");

DateTime DT = DateTime.Now.ToString("F");

结果:2018年11月22日13:00:00

Result: 22 November 2018 13:00:00

问题:它缺少我想要的日期名称。

Prob: it's missing the day name that I want.

使用 DateTimeFormatInfo。 GetAllDateTimePatterns('F'),我可以看到一些格式:dddd,dd MMMM YYYY

Using the DateTimeFormatInfo.GetAllDateTimePatterns('F'), I can see a few formats that have: dddd, dd MMMM YYYY

它会给我我想要的东西:

and it will give me exactly what I want:

2018年11月22日星期四13:00:00

Thursday, 22 November 2018 13:00:00

但是,这个想要的模式是另一个10,有些有dddd,有些没有。如何选择最好的dddd?我正在考虑获得第一个包含dddd的模式(使用string.contains())。它们是按优先级
顺序排序的吗?

However, this wanted pattern is one of another 10, some have the dddd, some do not. How can I select the best one that has dddd in it? I'm thinking of getting the first pattern that has the dddd in it (using string.contains()). Are they sorted in priority order?

谢谢。

Thanks.

推荐答案

好吧,
" F"是系统设置中定义的完整日期/时间模式
。因此,如果你没有得到这一天,这意味着你应该改变你的系统设置:

Well, "F" is the full date/time pattern as defined in the systems settings. Thus if you don't get the day, this means your should change your systems settings:


这篇关于选择正确的DateTimePattern的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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