57
1
using System;
2
using System.Globalization;
3
4
public class SamplesJulianCalendar {
5
6
public static void Main() {
7
8
// Sets a DateTime to April 3, 2002 of the Gregorian calendar.
9
DateTime myDT = new DateTime( 2002, 4, 3, new GregorianCalendar() );
10
11
// Creates an instance of the JulianCalendar.
12
JulianCalendar myCal = new JulianCalendar();
13
14
// Displays the values of the DateTime.
15
Console.WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Julian calendar:" );
16
DisplayValues( myCal, myDT );
17
18
// Adds two years and ten months.
19
myDT = myCal.AddYears( myDT, 2 );
20
myDT = myCal.AddMonths( myDT, 10 );
21
22
// Displays the values of the DateTime.
23
Console.WriteLine( "After adding two years and ten months:" );
24
DisplayValues( myCal, myDT );
Cached Result
April 3, 2002 of the Gregorian calendar equals the following in the Julian calendar:
Era: 1
Year: 2002
Month: 3
DayOfYear: 80
DayOfMonth: 21
DayOfWeek: Wednesday
After adding two years and ten months:
Era: 1
Year: 2005
Month: 1
DayOfYear: 21
DayOfMonth: 21
DayOfWeek: Thursday
Era: 1
Year: 2002
Month: 3
DayOfYear: 80
DayOfMonth: 21
DayOfWeek: Wednesday
After adding two years and ten months:
Era: 1
Year: 2005
Month: 1
DayOfYear: 21
DayOfMonth: 21
DayOfWeek: Thursday