在 SAP 系统中格式化日期


您需要将新文化应用于现有线程,如下所示

示例

DateTime now = DateTime.Now;
Console.WriteLine(now);
CultureInfo sapCulture = new CultureInfo("en-US", true);
sapCulture.DateTimeFormat.ShortDatePattern = "ddMMyyyy";

//sapCulture.DateTimeFormat.FullDateTimePattern =
   sapCulture.DateTimeFormat.ShortDatePattern + " HH-mm-ss";
sapCulture.DateTimeFormat.LongTimePattern = "HH-mm-ss";

//sapCulture.DateTimeFormat.ShortTimePattern = "HH-mm-ss";
System.Threading.Thread.CurrentThread.CurrentCulture = sapCulture;

//System.Threading.Thread.CurrentThread.CurrentUICulture = sapCulture;
Console.WriteLine(now);

更新时间:16-12-2019

118 次浏览

开启你的 职业生涯

完成课程以获得认证

开始
广告