在文化可变的情况下,格式化不含日期的本地化日期 [英] Formatting a localized date with out the year when the culture is variable
问题描述
我需要根据当前设置的区域性将日期显示为M/dd或dd/M.在我们的应用程序中,我们通过设置显式设置区域性.目前,我们使用以下方法设置日期格式:
I need to have my dates display in the either M/dd or dd/M depending on the currently set culture. With in our app we explicitly set the culture based off config. We currently format our dates using the following method:
string dateStringFormat =Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern;
someDate.ToString(dateStringFormat)
这会产生所需的日期字符串,并格式化为我们的设置区域性(即2013年10月4日或2013年10月4日).但是,当我需要日期不包括年份时,该如何做却仍使其可变?如果我做类似 someDate.ToString("dd/MM",dateStringFormat)
之类的事情,那么不管采用哪种文化,都不会总是将其保持为日/月格式吗?希望我的问题很清楚.感谢您提供任何可能的帮助.
This produces the desired date string formatted to our set culture (I.E. 10/4/2013 or 4.10.2013). But in the case when I need the date to not include the year how can I do that and still make it variable? If I do something like someDate.ToString("dd/MM", dateStringFormat)
wouldn't that always keep it in day/month format regardless of the culture? Hopefully my question is clear enough. Thanks for any possible help.