zoukankan      html  css  js  c++  java
  • Winfrom 设置PC 端日期格式

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    
    namespace ZB.QueueSys.Common
    {
        public class DateHelper
        {
            private static DateHelper instance;
            public static DateHelper Instance
            {
                get
                {
                    if (instance == null) instance = new DateHelper();
                    return DateHelper.instance;
                }
            }
    
    
            [DllImport("kernel32.dll", EntryPoint = "GetSystemDefaultLCID")]
            public static extern int GetSystemDefaultLCID();
            [DllImport("kernel32.dll", EntryPoint = "SetLocaleInfoA")]
            public static extern int SetLocaleInfo(int Locale, int LCType, string lpLCData);
            public const int LOCALE_SLONGDATE = 0x20;
            public const int LOCALE_SSHORTDATE = 0x1F;
            public const int LOCALE_STIME = 0x1003;
    
            public void SetDateTimeFormat()
            {
                try
                {
                    int x = GetSystemDefaultLCID();
                    SetLocaleInfo(x, LOCALE_STIME, "HH:mm:ss");        //时间格式
                    SetLocaleInfo(x, LOCALE_SSHORTDATE, "yyyy-MM-dd");   //短日期格式  
                    SetLocaleInfo(x, LOCALE_SLONGDATE, "yyyy-MM-dd");   //长日期格式 
                }
                catch { return; }
            }
    
        }
    }
    

      

  • 相关阅读:
    「LibreOJ β Round #4」子集
    「LibreOJ β Round #4」框架
    「LibreOJ β Round #4」游戏
    [HNOI2008]GT考试
    [HNOI2008]水平可见直线
    UVA 1650 Number String
    [USACO14JAN]Recording the Moolympics
    UVA 1390 Interconnect
    UVA 12520 Square Garden
    [HNOI2008]神奇的国度
  • 原文地址:https://www.cnblogs.com/YYkun/p/12744535.html
Copyright © 2011-2022 走看看