So I know I can format dates like

<apex:outputText value="{0, date, MMMM d','  yyyy}">
    <apex:param value="{!contact.Birthdate}" /> 

and this outputs e.g. January 5, 2016.

But what if I want this to show in e.g. Dutch, so that the date would become 5 januari, 2016. Can this be done by changing the above outputText or should I roll my own property on the controller that generates the date for me? In case of the latter, is there a standard library that already does this?

  • So for a User whose locale is set to one value, you want to format specific date fields in another locale? Interested to know why...
    – Keith C
    Commented Oct 6, 2015 at 12:55
  • It's for visualforce email templates where we send mail to contacts in their own locale. Commented Oct 6, 2015 at 13:22
  • Looks like a common problem with no clean solution e.g. Visualforce Email template to display date and time in User's timezone (local time).
    – Keith C
    Commented Oct 6, 2015 at 13:50
  • Presumably the templates are not Visualforce where the apex:page language attribute could be used (which I assume affects date format as well as labels)?
    – Keith C
    Commented Oct 6, 2015 at 14:04
  • @WillemMulder could you find a solution for displaying locale based day names ?
    – owsata
    Commented Mar 14, 2018 at 14:03

3 Answers 3

{! DAY(Contact.BirthDate)}
<apex:outputText value="{!CASE(MONTH(Contact.BirthDate),
                        1, 'Januari',
                        2, 'Februari',
                        3, 'Maart', 
                        4, 'April', 
                        5, 'Mei', 
                        6, 'Juni',
                        7, 'Juli',
                        8, 'Augustus',
                        9, 'September',
                        10, 'Oktober',
                        11, 'November',
                        12, 'December',
                        '-')}" />

A few years late, but I think ultimately you are not going to find a satisfactory answer to this. Salesforce has not given Visualforce/Apex access to a comprehensive resource for international day/month names.

Your best bet might be to make a reusable Visualforce component. The component can take in a Date or Datetime and have a controller of its own that retrieves day/month maps from some source (Custom Metadata? Labels? Etc) and does the formatting. You'll end up with reusable code you can use in many projects, and then you can include it in VF with a simple tag syntax.


Have you tried doing this - may be work

<apex:outputText value="{0,date,dd MMMM',' yyyy}">
    <apex:param value="{!contact.Birthdate}" /> 

Edit :

If not expected result then Go through this - (Talking about Locality)

How to use output text date format to respect locale

Visualforce Component for Locale Based DateTime Display

  • Yes I tried that already, it only moves things around, it doesn't actually translate into a different locale. Commented Oct 6, 2015 at 12:37
  • check out edits Commented Oct 6, 2015 at 12:44
  • Thanks, that is useful for half of the question: how to order the different date elements. The other part still stands: how to actually translate and display the MMMM part. Commented Oct 6, 2015 at 13:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .