• 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; }
            }
    
        }
    }
    

      

  • 相关阅读:
    判断具有某个属性js、jQuery
    新建maven项目,JRE System Library[J2SE-1.5]
    maven多模块搭建
    The POM for * is invalid
    【react】react-bookManager
    【cml】wosi-demo
    关于白盒测试
    【weex】h5weex-example
    【weex】publishTask
    Eslint报错的翻译
  • 原文地址:https://www.cnblogs.com/YYkun/p/12744535.html
Copyright © 2020-2023  润新知