@Stéphane Mons : I tried to follow your instructions, and I hope you can spot something wrong in my code below, because, testing the built app, whatever preferred language I choose I always get its English rendering.
Again, I hope the fault is that I could not find the "StringFromDate method" you suggested. That's way I first tried
mformatter.StringValue(mNSDate), but it returns no text;
while using mformatter.LocalizedString(mNSDate, etc.) it returns the right date although in English.
BTW: The code is in the action event of a button.
Added more code in [Edited] at the bottom.
MacOSLib's NSLocale.currentLocale will give you the preferred language for the OS (the SystemLocale is a trap, don't use it)
Create a NSDateFormatter object and set its locale to the one from step 1
Use the formatter StringFromDate method to convert a NSDate into a String
//dim mCurrentLocale as Cocoa.NSLocale = Cocoa.NSLocale.SystemLocale
dim mCurrentLocale as NSLocale = NSLocale.CurrentLocale
dim mFormatter as new Cocoa.NSDateFormatter
mFormatter.Locale = mCurrentLocale
dim d as new date
d.Year = 2001
d.Month = 9
d.day = 5
d.TotalSeconds = d.TotalSeconds
dim mNSDate as new Cocoa.NSDate
mNSDate = d//mNSDate.Now
//MsgBox mformatter.StringValue(mNSDate)//always void string
MsgBox mformatter.LocalizedString(mNSDate,Cocoa.NSDateFormatter.NSDateFormatterStyle.NSDateFormatterFullStyle, _
I forgot to mention that my first attempt was to use mformatter.LocalizedDateFormat, since it takes Locale as a parameter.
But I could not build the expected structured date-string:
dim myDate as string = d.longDate
Attempting to use NSDateComponents, I fail to see how to make a string from it.
'dim mDateComp as Cocoa.NSDateComponents
'mDateComp.Year = 2017
'mDateComp.Month = 11
'mDateComp.day = 05
MsgBox mformatter.LocalizedDateFormat(myDate, mCurrentLocale)//it returns garbage
Any idea how to proceed?