Note that there are some explanatory texts on larger screens.

plurals
  1. POFormatting numerals and dates in other locales in C#/.NET
    primarykey
    data
    text
    <p>In an application I'm writing I want to display the current date and time, in English, but also in other locales.</p> <p>For example Russian, Arabic and Chinese.</p> <pre><code>// DateTime.ToLongDateString doesn't support a IFormatProvider parameter DateTime.Now.ToString("dddd, d MMMM, yyyy", new CultureInfo("en-US")); // "Wednesday, 7 August, 2013" DateTime.Now.ToString("dddd, d MMMM, yyyy 'r.'", new CultureInfo("ru-RU")); // "среда, 7 августа, 2013 r." </code></pre> <p>Works fine...</p> <pre><code>DateTime.Now.ToString("dddd٫ d MMM٫ yyyy", new CultureInfo("ar")); // "الأربعاء٬ 30 رمضان٬ 1434" </code></pre> <p>Seems to work fine.</p> <p><em>However...</em> I'd like to show the numerals as (Eastern) Arabic numerals, not as Latin/Arabic numerals. Though this could of course be solved by doing a simple substitution ('٠‎' to '0', 1 to '١' etc).</p> <p>But then there's Chinese:</p> <pre><code>DateTime.Now.ToString("yyyy年M月d日dddd", new CultureInfo("zh-CN")) // "2013年8月7日星期三" </code></pre> <p><a href="http://en.wikipedia.org/wiki/Chinese_numeral#Written_numbers" rel="noreferrer">Chinese numerals</a> seem to be quite a bit more complex than just doing a simple substitution; sometimes one character becomes 2. Next to that, The formatted date seems to show the current Gregorian date, not the <a href="https://en.wikipedia.org/wiki/Chinese_calendar" rel="noreferrer">current Chinese date</a>.</p> <p><strong>So my question is:</strong></p> <p>A) Is there any localization functionality in .NET/C# to display numbers (specificly dates) in other numeralsystems?</p> <p>B) Can i force .NET/C# to display dates in the Chinese (and possibly Japanese and other) calendars, as it seems to do with the Arabic calendar?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload