CSharp examples for System:DateTime Convert
Converts the Gregorian date to Umm Al Qura date as int.
using System.Text; using System.Linq; using System.Globalization; using System.Collections.Generic; using System;/*ww w .ja v a2s . c om*/ public class Main{ /// <summary> /// Converts the Gregorian date to UmAlQura date as int. /// </summary> /// <param name="gregDate">The Gregorian date.</param> /// <returns>UmAlQura date as int</returns> public static int ConvertGregToUmAlQura(this DateTime gregDate) { System.Globalization.UmAlQuraCalendar calendar = new System.Globalization.UmAlQuraCalendar(); string year = calendar.GetYear(gregDate).ToString(); string month = calendar.GetMonth(gregDate).ToString(); if (month.Length < 2) month = "0" + month; string day = calendar.GetDayOfMonth(gregDate).ToString(); if (day.Length < 2) day = "0" + day; return int.Parse(year + month + day); } }