Date format similar to NSDateFormatterMediumStyle for Monotouch?

I am trying to format the date as it appears in the iOS calendar application.

The format is NSDateFormatterMediumStyle and displays a date such as November 27, 2011. Documentation

However, this format is not available in the .NET Framework date formats, so I have to use NSDateFormatter to format the date. Documentation

The problem is that in Monotouch I cannot find a method in NSDateFormatter to format the date. Apple examples have [dateFormatter stringFromDate: date]; however, does this method seem to be missing from Monotouch or is there an alternative?

+4
source share
2 answers

Jason's comment makes a lot of sense about using Rosetta . It shows that the stringFromDate:date selector is a binder in the NSDateFormatter type.

Note: since most of the database code (shared by MonoTouch and MonoMac) is open source, you can also find binding sources on github .

From the above, I assume that you should be able to get the results you are looking for (e.g. iOS, not .NET, culture-oriented date / time strings):

 var f = new NSDateFormatter (); f.DateStyle = NSDateFormatterStyle.Medium; string result = f.ToString (nsdate); 
+3
source

.NET supports custom date formats . This should do what you want:

 myDate.ToString("MMM d, yyy"); 
+2
source

Source: https://habr.com/ru/post/1383306/


All Articles