开发者

.NET date formatting

Consider:

Assert.Eq开发者_StackOverflow中文版ual("11 Aug 2010", date.ToString(???);

Somehow ToString("d MMM yyyy") outputs "11 aug 2010". How can I make it to be Aug instead of aug?


ToString("d MMM yyyy", CultureInfo.CreateSpecificCulture("en-US")

works


In that case how about using ToTitleCase():

ToTitleCase() method is hidden treasure of .Net Framework hosted by the System.Globalization.TextInfo namespace and can be used as shown below:

string sentence = "this is a title case EXAMPLE sentence";
string formattedSentence = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(sentence.ToLower());

Will result in "This Is A Title Case Example Sentence"


I have this cheat sheet website that i have saved to my favourites

http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜