How to set date format for apex:outputText?

Sample Code:

Visualforce page:

<apex:page controller="Sample" >
    <apex:form >        
         <apex:outputText value="{0,date,dd'/'MM'/'yyyy}" >
             <apex:param value="{!temp}"/>
         </apex:outputText>
    </apex:form>
</apex:page>



Apex Controller:

public with Sharing class Sample
{   
    public Date gettemp()
    {
        Date d = date.ValueOf('2013-12-10');
        return d;
    }
    public List<Member__c> mem {get;set;}   
      
    public sample()
    {
    }
}


Output:



Note: Make sure 'MM' is alone in capital letters.

Cheers!!!!

No comments:

Post a Comment