Vb.net如何获取特定工作日的名称?

2026-05-06 08:211阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计241个文字,预计阅读时间需要1分钟。

Vb.net如何获取特定工作日的名称?

今天日期是2012年10月21日,这是周末。但我的VB.NET认为日期格式不同:Debug.Print(本周对于日期 '21.10.2012' 是 + WeekdayName(Weekday(21.10.2012))),而Debug.Print(本周对于日期 '21/10/2012' 是 + WeekdayName(Weekday(21/10/2012)))。

今天是21.10.2012.这是星期天
但我的VB.NET认为不同:

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)

标签:今天

本文共计241个文字,预计阅读时间需要1分钟。

Vb.net如何获取特定工作日的名称?

今天日期是2012年10月21日,这是周末。但我的VB.NET认为日期格式不同:Debug.Print(本周对于日期 '21.10.2012' 是 + WeekdayName(Weekday(21.10.2012))),而Debug.Print(本周对于日期 '21/10/2012' 是 + WeekdayName(Weekday(21/10/2012)))。

今天是21.10.2012.这是星期天
但我的VB.NET认为不同:

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)

标签:今天