Csharp/C Sharp/Development Class/Calendar — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 11:43, 26 мая 2010
Содержание
Calendar ToDateTime is not culture aware
using System;
using System.Globalization;
class Class1
{
static void Main(string[] args)
{
Calendar MyCalendar = new GregorianCalendar();
CultureInfo MyCulture = new CultureInfo("es-ES");
DateTime MyDate = new DateTime(2006,8,22,15,30,0,0);
//
Console.WriteLine(MyCalendar.ToDateTime(MyDate.Year,
MyDate.Month,
MyDate.Day,
MyDate.Hour,
MyDate.Minute, 0, 0));
}
}
To Four Digit Year
using System;
using System.Globalization;
class Class1
{
static void Main(string[] args)
{
Calendar MyCalendar = new GregorianCalendar();
Console.WriteLine(MyCalendar.ToFourDigitYear(32));
Console.WriteLine(MyCalendar.ToFourDigitYear(28));
}
}
ToString(): make it culture aware
using System;
using System.Globalization;
class Class1
{
static void Main(string[] args)
{
Calendar MyCalendar = new GregorianCalendar();
CultureInfo MyCulture = new CultureInfo("es-ES");
DateTime MyDate = new DateTime(2006,8,22,15,30,0,0);
Console.WriteLine(MyCalendar.AddMinutes(MyDate, 15).
ToString("G",
MyCulture));
}
}
Two Digit Year Max
using System;
using System.Globalization;
class Class1
{
static void Main(string[] args)
{
Calendar MyCalendar = new GregorianCalendar();
CultureInfo MyCulture = new CultureInfo("es-ES");
DateTime MyDate = new DateTime(2006,8,22,15,30,0,0);
Console.WriteLine(MyCalendar.TwoDigitYearMax);
}
}