Share via

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");
        }
    }
}
Developer technologies | Windows Forms
Developer technologies | C++
Developer technologies | 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.

0 comments No comments

Answer accepted by question author

  1. Daniel Zhang-MSFT 9,661 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 126.9K 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.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.