Groups | Blog | Home
all groups > dotnet sdk > april 2005 >

dotnet sdk : Date formatting


KDV
4/4/2005 8:15:06 AM
I am using the the date format string "dddd, MMMM dd, yyyy" which formats
Date type to Monday, April 04, 2005. Is there any way I can specify in the
format string so that the day should be in capital letter eg MONDAY, April
04, 2005. I don't want to parse myself.

katyk NO[at]SPAM online.microsoft.com
4/4/2005 9:28:17 PM
| From: =?Utf-8?B?S0RW?= <kdv@discussions.microsoft.com>
|
| I am using the the date format string "dddd, MMMM dd, yyyy" which formats
| Date type to Monday, April 04, 2005. Is there any way I can specify in
the
| format string so that the day should be in capital letter eg MONDAY,
April
| 04, 2005. I don't want to parse myself.

You can define your own array of day names, and format with it:

DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
dtfi.DayNames = new String[] { "SUNDAY", "MONDAY", "TUESDAY",
"WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", };
Console.WriteLine(dt.ToString("dddd, MMMM dd, yyyy", dtfi));

Parsing should already be case-insensitive.

Katy
CLR Testing
KDV
4/5/2005 8:35:06 AM
Thanks Karty. Actually in my application I was storing only the date format
string which was controlling how the date will be formatted. With this
approach I don't have to store only the date mask but also additional info
like whether to display Days/Months in uppercase or lowercase.( 24 entries
for the month JAN/JANUARY
and 14 for the Days SUN/SUNDAY). I think this is the way it gonna work.

Thanks for the reply

[quoted text, click to view]
AddThis Social Bookmark Button