+ 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!