Hijiri Calender and converting the selected date to Gregorian calender value

I am developing a windows based application. Here i want to use the Hijiri Calender.
I like to look the calender as a date picker control and the selected date want to get also in Gregorian calender date.
Cannot find successful conversion method for the date conversion.

Jon Skeet
people
quotationmark

I don't know anything about the UI side of things (I don't know which date picker you're using, or whether it supports alternative calendars), but... if you've got a DateTime value representing a Hijri date, that's always effectively in the Gregorian calendar. You can get the year/month/day values in the Hijri calendar with:

var calendar = new HijriCalendar();
var gregorian = ...; // The DateTime value
var hijriYear = calendar.GetYear(gregorian);
var hijriMonth = calendar.GetMonth(gregorian);
var hijriDay = calendar.GetDayOfMonth(gregorian);

Alternatively, you might want to consider using my Noda Time project, where a LocalDate value knows which calendar it's in:

// Equivalent to HijriCalendar
CalendarSystem hijriCalendar = CalendarSystem.GetIslamicCalendar
    (IslamicLeapYearPattern.Base16, IslamicEpoch.Astronomical)
LocalDate gregorian = ...; // Wherever
LocalDate hijri = gregorian.WithCalendar(hijriCalendar);

You may well find it's harder to use Noda Time at the UI side, but easier to use properly for the rest of your code. It depends on what you're trying to do.

people

See more on this question at Stackoverflow