c# - Best way to display locale-aware date with abbreviated month name? -
In my application, I use a kind of friendly short date format for NGM Locale, this' MMM Yay ', i.e. 1 June 2014.
How can I create a locally-conscious format which uses a short month format and is thus suited to any place (as defined by CurrentCulture)?
I thought of something like this:
System.Globalization.CultureInfo cI = System.Globalization.CultureInfo.CurrentCulture; ("DD", "D"). (CI.DateTimeFormat.DateSeparator, ""); Replace.
But - every locale does not have 'MM', some use 'M' in the shortcut pattern. And I do not think that I can take the place of a separator from the "trustworthy" bus. Or i?
Any suggestions? Maybe it would be better to start with a long datetime format and clear it?
Take the culture as you
var culture = System.blobalization.cultureInfoContentCulture;
and then it and dateTime.ToString
overload
date.ToString ("MMMM d MMMM", using the culture Format it);
(But this will explode because Bella memory is limited).
If you want the date displayed for the user's date (order and delimiter), you should avoid using anything other than ShortDatePattern
already You can try to replace "MM"
with "M"
with "MMMM"
, but told you that it still The user will
Perhaps you can use MonthDayPattern
as John Skeet (but still not recommended) and just any By the way indicate (in the brackets after that)
Comments
Post a Comment