获取区域性特定日期2位数年在C#数年、区域性、日期

由网友(何似在人间)分享简介:我更新了一些code表示格式的日期,使用MM / DD / YY的字符串。我需要它是文化的了解,但要保持两位数的年份,以保持日期短。下面是我想出了,但有没有更好的办法?字符串DATEFORMAT = culture_Info.DateTimeFormat.ShortDatePattern.Replace(YYYY,YY...

我更新了一些code表示格式的日期,使用MM / DD / YY的字符串。我需要它是文化的了解,但要保持两位数的年份,以保持日期短。下面是我想出了,但有没有更好的办法?

 字符串DATEFORMAT = culture_Info.DateTimeFormat.ShortDatePattern.Replace(YYYY,YY);
 

解决方案

我不知道有什么办法,没有(和我看的格式相当广泛)。你有什么明显仍有一点在嘴里讨厌的味道,但我认为这是最好的,你可以做的。

I'm updating some code that formats a date to a string using "MM/dd/yy". I need it to be culture aware, but want to keep the two digit year in order to keep the date short. Below is what I came up with, but is there a better way?

string dateFormat = culture_Info.DateTimeFormat.ShortDatePattern.Replace("yyyy", "yy");
预测一下,新型冠状病毒何时在武汉停止传播

解决方案

I don't know of any way, no (and I've looked at the formatting reasonably extensively). What you've got obviously still leaves a bit of a nasty taste in the mouth, but I think it's the best you can do.

阅读全文

相关推荐

最新文章