C#中把星期英文格式转换成中文 在报表中要求把报表中的日期转换成星期格,但用DateTime.DayOfWeek转换出来后是英文,求怎样转成汉字形式呀,急,在线等待 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 WeekdayName(周几,是否缩写, 第一天是周几) System.Threading.Thread currentThread = System.Threading.Thread.CurrentThread;System.Globalization.CultureInfo cultureInfo = (System.Globalization.CultureInfo)currentThread.CurrentCulture.Clone(); string buffer = cultureInfo.DateTimeFormat.GetAbbreviatedDayName(System.DayOfWeek.Friday);//buffer =星期五 try..Console.WriteLine(System.DateTime.Now.GetDateTimeFormats('D')[2].Substring (0,3).ToString ()); string str=System.DateTime.Now.GetDateTimeFormats('D')[2].Substring (0,3).ToString (); System.Globalization.CultureInfo cultureInfo = new CultureInfo("zh-CN");string buffer = cultureInfo.DateTimeFormat.GetAbbreviatedDayName(System.DayOfWeek.Friday);这样在英文环境下也可以得到正确的 string str=System.DateTime.Now.GetDateTimeFormats('D')[2].Substring (0,3).ToString ();输出:星期二 System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("zh-CN"); textBox1.Text = cultureInfo.DateTimeFormat.GetAbbreviatedDayName(dt.DayOfWeek).ToString(); textBox1.Text = dt.GetDateTimeFormats('D')[2].Substring(0, 3).ToString(); switchi can do it only in this way. Console.WriteLine(System.DateTime.Now.GetDateTimeFormats('D')[2].ToString()); 这个 谁能给我讲讲'D'代表什么 格式字符 关联属性/说明 d ShortDatePattern D LongDatePattern f 完整日期和时间(长日期和短时间) F FullDateTimePattern(长日期和长时间) g 常规(短日期和短时间) G 常规(短日期和长时间) m、M MonthDayPattern r、R RFC1123Pattern s 使用当地时间的 SortableDateTimePattern(基于 ISO 8601) t ShortTimePattern T LongTimePattern u UniversalSortableDateTimePattern 用于显示通用时间的格式 U 使用通用时间的完整日期和时间(长日期和长时间) y、Y YearMonthPattern 最好别使用GetDateTimeFormats方法,因为不同操作环境会不一样的。 string week = yourDateTime.ToString("dddd", new System.Globalization.CultureInfo("zh-CN")); (新手- -!)C# 引用 继承 的问题? 想做插件。有经验的朋友们进来大家共同学习 求讲解下我这代码原理?(迷糊) 窗口打开前的等待图怎么实现? 轻轻的问一个问题~~如何解释"DataGridView" 和"DataView"的区别比较让人容易理解! C#中想用messageBox这个类,为什么要添加System.Windows.Forms这个引用之后才能用? 如何在winform里嵌入ie? C#接口的实现中不能有static,但有个疑问 C#的项目文件,不能放到网络盘上吗? 请教下关于 父类如何调用子类方法的问题 SQL连接字符串的问题在线等 c#连接到ftp的问题
System.Globalization.CultureInfo cultureInfo = (System.Globalization.CultureInfo)currentThread.CurrentCulture.Clone();
string buffer = cultureInfo.DateTimeFormat.GetAbbreviatedDayName(System.DayOfWeek.Friday);//buffer =星期五
string buffer = cultureInfo.DateTimeFormat.GetAbbreviatedDayName(System.DayOfWeek.Friday);
这样在英文环境下也可以得到正确的
System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("zh-CN");
textBox1.Text = cultureInfo.DateTimeFormat.GetAbbreviatedDayName(dt.DayOfWeek).ToString(); textBox1.Text = dt.GetDateTimeFormats('D')[2].Substring(0, 3).ToString();
这个 谁能给我讲讲'D'代表什么
关联属性/说明
d
ShortDatePattern
D
LongDatePattern
f
完整日期和时间(长日期和短时间)
F
FullDateTimePattern(长日期和长时间)
g
常规(短日期和短时间)
G
常规(短日期和长时间)
m、M
MonthDayPattern
r、R
RFC1123Pattern
s
使用当地时间的 SortableDateTimePattern(基于 ISO 8601)
t
ShortTimePattern
T
LongTimePattern
u
UniversalSortableDateTimePattern 用于显示通用时间的格式
U
使用通用时间的完整日期和时间(长日期和长时间)
y、Y
YearMonthPattern