3

I'm searching to change the display language of my date with it :

<apex:outputText value="{0, date, 'le 'dd ' ' MMMM yyyy}">
    <apex:param value="{!NOW()}"/>
</apex:outputText>

but i would like display the month in french and not in english. Ty for your help.

3 Answers 3

0

One solution could be use of the formula CASE and set the month manually depending on the month digit. But it is not a best practice:

<apex:outputText value="{!CASE(MONTH(DATEVALUE(NOW())),
                                1, 'Janvier',
                                2, 'Février',
                                3, 'Mars', 
                                4, 'Avril', 
                                5, 'Mai', 
                                6, 'Juin',
                                7, 'Juillet',
                                8, 'Août',
                                9, 'Septembre',
                                10, 'Octobre',
                                11, 'Novembre',
                                12, 'Décembre',
                                '-')}" />

You better format the date in Apex, it is much comfortable.

1
  • Ho, ty, i tried this practice but I failed, bad use. not really the best like you said but it's efficient. TY
    – user17624
    Mar 5, 2015 at 15:13
1

I advise to format the date in Apex. You could do something like the following:

// Add those two properties in your Apex controller
private Map<Integer, String> frenchDates = new Map<Integer, String>();
frenchDates.put(1, 'Janvier')
frenchDates.put(2, 'Février')
frenchDates.put(3, 'Mars')
frenchDates.put(4, 'Avril')
frenchDates.put(5, 'Mai')
frenchDates.put(6, 'Juin')
frenchDates.put(7, 'Juillet')
frenchDates.put(8, 'Aout')
frenchDates.put(9, 'Septembre')
frenchDates.put(10, 'Octobre')
frenchDates.put(11, 'Novembre')
frenchDates.put(12, 'Décembre')

private String formattedDate {
    get {
        Datetime dateNow = Datetime.now();
        return String.valueOf(dateNow.day()) + frenchDates.get(dateNow.month()) + String.valueOf(dateNow.year());
    }
    set;
}

Then just use formattedDate property directly in your Visualforce page.

1
  • OK thanks,i keep it for later. TY all
    – user17624
    Mar 5, 2015 at 15:59
0

I believe this should be taken care of automatically if you just set your language locale to French on your user record.

1
  • I tried it but it didn't work. Maybe I failed.
    – user17624
    Mar 5, 2015 at 15:14

You must log in to answer this question.

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