How do I code "day of the week" in Japanese in Visual Studios?

Danleif 41 Reputation points
2021-02-28T13:32:22.273+00:00

I am making a clock in a Windows Forms App. Now "ddd" displays "Mon", for example. But I want it to say "月". Currently Form1 has:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Aesthetic_Date_Clock
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void tmrTimer_Tick(object sender, EventArgs e)
        {
            label1.Text = DateTime.Now.ToString("HH : mm : ss");
            label2.Text = DateTime.Now.ToString("yy / MM / dd");
            label3.Text = DateTime.Now.ToString("ddd");
        }
    }
}
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,858 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,571 questions
0 comments No comments
{count} votes

Accepted answer
  1. Daniel Zhang-MSFT 9,621 Reputation points
    2021-03-01T02:46:02.177+00:00

    Hi Danleif-7903,
    You can use DateTime.DayOfWeek property to get the day of the week represented by this instance.
    Please refer to the following code:

    var culture = new System.Globalization.CultureInfo("ja-JP");  
    var day = culture.DateTimeFormat.GetDayName(DateTime.Today.DayOfWeek);  
    label3.Text = day;  
    

    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Viorel 113.4K Reputation points
    2021-02-28T13:54:17.03+00:00

    Try this fragment:

    CultureInfo c = CultureInfo.GetCultureInfo( "ja-JP" );
    CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = c;
    
    DateTime now = DateTime.Now;
    
    label1.Text = now.ToLongTimeString( );
    label2.Text = now.ToShortDateString( );
    label3.Text = now.ToString( "ddd" );
    
    1 person found this answer helpful.