Converts DateTimeOffset to string using the specified format and culture-specific format information.
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
CultureInfo arSA = new CultureInfo("ar-SA");
arSA.DateTimeFormat.Calendar = new UmAlQuraCalendar();
DateTimeOffset date1 = new DateTimeOffset(new DateTime(1890, 9, 10),
TimeSpan.Zero);
try {
Console.WriteLine(date1.ToString("d", arSA));
}
catch (ArgumentOutOfRangeException) {
Console.WriteLine("{0:d} is earlier than {1:d} or later than {2:d}",
date1,
arSA.DateTimeFormat.Calendar.MinSupportedDateTime,
arSA.DateTimeFormat.Calendar.MaxSupportedDateTime);
}
}
}
Related examples in the same category