Arnis Lapsa
Arnis Lapsa

Reputation: 47567

.NET date formatting

Consider:

Assert.Equal("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?

Upvotes: 0

Views: 140

Answers (3)

Iain
Iain

Reputation: 6452

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

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

Upvotes: 0

Xander
Xander

Reputation: 1133

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"

Upvotes: 0

Arnis Lapsa
Arnis Lapsa

Reputation: 47567

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

works

Upvotes: 4

Related Questions