Vb.net得到了工作日的名字
发布时间:2020-12-17 07:22:37 所属栏目:百科 来源:网络整理
导读:今天是21.10.2012.这是星期天 但我的VB.NET认为不同: Debug.Print("Weekday for the date '21.10.2012.'is " WeekdayName(Weekday("21.10.2012.")))Debug.Print("Weekday for the date '21/10/2012'is " WeekdayName(Weekday("21/10/2012")))Debug.Print("W
今天是21.10.2012.这是星期天
但我的VB.NET认为不同: Debug.Print("Weekday for the date '21.10.2012.'is " & WeekdayName(Weekday("21.10.2012."))) Debug.Print("Weekday for the date '21/10/2012'is " & WeekdayName(Weekday("21/10/2012"))) Debug.Print("Weekday for the date '" & DateTime.Now.Date & "'is " & WeekdayName(Weekday(DateTime.Now.Date))) 所有这3张支票都给我:工作日名称’星期一’! 解决方法
这是获取给定日期的工作日名称的正确.NET方法:
Dim myCulture As System.Globalization.CultureInfo = Globalization.CultureInfo.CurrentCulture Dim dayOfWeek As DayOfWeek = myCulture.Calendar.GetDayOfWeek(Date.Today) ' dayOfWeek.ToString() would return "Sunday" but it's an enum value,' the correct dayname can be retrieved via DateTimeFormat. ' Following returns "Sonntag" for me since i'm in germany ' Dim dayName As String = myCulture.DateTimeFormat.GetDayName(dayOfWeek) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |