I'd like to get localized date in my Xamarin Forms app. I have tried two ways that work just fine in ASP.NET MVC, but I wonder why neither of them works in Xamarin.
var currentDate DateTime.Now.ToString("yyyy/mm/dd", new CultureInfo("fa-IR"))
And by using culture info's calendar:
var month = new CultureInfo("fa-IR").Calendar.GetMonth(DateTime.Now);
Both of these methods gave me the current date in en-US
.
Apparently, PersianCalendar
is supposed to be there. I can't understand what I'm missing?
I even tried NodaTime by, SystemClock.Instance.Now.InZone(DateTimeZoneProviders.Tzdb["Asia/Tehran"]).Date.ToString()
and the date is still in default culture!
UPDATE
Finally, Persian Calendar Plus did the job! But it would be very useful if someone could get the bottom of it!