zoukankan      html  css  js  c++  java
  • 用C#代码修改区域与语言的短日期格式

     1         [DllImport("kernel32.dll", EntryPoint = "GetSystemDefaultLCID")]   
     2         public static extern int GetSystemDefaultLCID();   
     3         [DllImport("kernel32.dll", EntryPoint = "SetLocaleInfoA")]   
     4         public static extern int SetLocaleInfo(int Locale, int LCType, string lpLCData);   
     5         public const int LOCALE_SLONGDATE = 0x20;   
     6         public const int LOCALE_SSHORTDATE = 0x1F;   
     7         public const int LOCALE_STIME = 0x1003;   
     8            
     9         public void SetDateTimeFormat()   
    10         {   
    11             try  
    12             {   
    13                 int x = GetSystemDefaultLCID();   
    14                 SetLocaleInfo(x, LOCALE_STIME, "HH:mm:ss");        //时间格式   
    15                 SetLocaleInfo(x, LOCALE_SSHORTDATE, "yyyy-MM-dd");   //短日期格式     
    16                 SetLocaleInfo(x, LOCALE_SLONGDATE, "yyyy-MM-dd");   //长日期格式    
    17             }   
    18             catch (Exception ex)   
    19             {   
    20                 Console.WriteLine(ex);   
    21             }   
    22         }  
  • 相关阅读:
    移动端兼容
    三点优化
    面向对象(一)
    BootCDN和npm
    分页逻辑
    多物体运动框架
    兼容样式
    省略
    行内元素在水平和垂直排列的时候会有间距
    [Swift]LeetCode1053.交换一次的先前排列 | Previous Permutation With One Swap
  • 原文地址:https://www.cnblogs.com/NoRoad/p/2130752.html
Copyright © 2011-2022 走看看