Add to year, month, week, day, hour, minute, second and millisecton : Calendar « Date Time « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » Date Time » CalendarScreenshots 
Add to year, month, week, day, hour, minute, second and millisecton
 


using System;
using System.Globalization;


public class MainClass{

   public static void Main()  {
      DateTime myDT = new DateTime2010413new GregorianCalendar() );

      Calendar myCal = CultureInfo.InvariantCulture.Calendar;

      myDT = myCal.AddYearsmyDT, );
      myDT = myCal.AddMonthsmyDT, );
      myDT = myCal.AddWeeksmyDT, );
      myDT = myCal.AddDaysmyDT, );
      myDT = myCal.AddHoursmyDT, );
      myDT = myCal.AddMinutesmyDT, );
      myDT = myCal.AddSecondsmyDT, );
      myDT = myCal.AddMillisecondsmyDT, );

      DisplayValuesmyCal, myDT );

   }

   public static void DisplayValuesCalendar myCal, DateTime myDT )  {
      Console.WriteLine"Era:          {0}", myCal.GetEramyDT ) );
      Console.WriteLine"Year:         {0}", myCal.GetYearmyDT ) );
      Console.WriteLine"Month:        {0}", myCal.GetMonthmyDT ) );
      Console.WriteLine"DayOfYear:    {0}", myCal.GetDayOfYearmyDT ) );
      Console.WriteLine"DayOfMonth:   {0}", myCal.GetDayOfMonthmyDT ) );
      Console.WriteLine"DayOfWeek:    {0}", myCal.GetDayOfWeekmyDT ) );
      Console.WriteLine"Hour:         {0}", myCal.GetHourmyDT ) );
      Console.WriteLine"Minute:       {0}", myCal.GetMinutemyDT ) );
      Console.WriteLine"Second:       {0}", myCal.GetSecondmyDT ) );
      Console.WriteLine"Milliseconds: {0}", myCal.GetMillisecondsmyDT ) );
   }

}

   
  
Related examples in the same category
1.Calendar ToDateTime is not culture aware
2.ToString(): make it culture aware
3.Two Digit Year Max
4.To Four Digit Year
5.Create date of 1/13/2009 using Hijri calendar and get Day property from DateTime
6.Calendar represents time in divisions, such as weeks, months, and years.
7.DateTime(Int32, Int32, Int32, Calendar): Create a DateTime structure to the specified year, month, and day for the specified calendar.
8.Using the Hijri Calendar
9.Using the Persian Calendar
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.