Search code examples
salesforcevisualforce

Can I get locale format for apex:outputText?


I know that you can format a date like this:

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

However, my application will be distributed to multiple countries. On some (such as mine), date format is dd/MM/yyyy, but on others (such as in the US) the format is MM/dd/yyyy.

Is there a way I can tell Visualforce to use the locale's short date format?


Solution

  • Apex param based formating is based on Java's MessageFormat:

    <apex:outputText value="{0, date, short}">
        <apex:param value="{!contact.Birthdate}" /> 
    </apex:outputText>