O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Determine Days of the Week, Leap Years, and More

Problem

You want to determine date information, such as what day of the week a given date falls on, whether a year is a leap year, and how many days are in a month.

Solution

Use a Calendar-derived class from the System.Globalization namespace, such as GregorianCalendar, or use the properties of a DateTime object.

Discussion

The System.Globalization namespace includes classes that contain culture-related calendar information. These classes derive from the base class Calendar and include GregorianCalendar (the Western standard), HebrewCalendar, JulianCalendar, JapaneseCalendar, and so on.

The Calendar classes define a number of basic methods, including:

  • GetDaysInMonth returns the number of days in a given ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required