function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
daniel.cecil.devdaniel.cecil.dev 

Date Format Language

Hello,

 

I'm trying to format a date's month in the user's language but keep getting it in English.

Here's the code I have:

 

Datetime d = System.now();
Datetime thisDate = DateTime.newInstance(d.year(), d.month(), d.day());
String format = thisDate.format('MMMM');
System.debug(format);

 Any ideas?

Many thanks, Dan

WilmerWilmer

Take the month as a number and create a custom apex class, wich reads that number and set the corresponding month name in the language you want by using custom labels (if your org is multilanguage you can set several languages values to the same label).

daniel.cecil.devdaniel.cecil.dev

Oh I thought that might be the case.. was looking for an easier solution. It should be implemented in Salesforce as I would have thought it's a pretty popular requirement?

 

Thanks for your help!

Dan

Phil WPhil W
It's 2018 and this is (I believe) still the case! Madness!