How to format date in Apex VisualForce

Posted on 21-02-2013 09:47 by graham
To format a date on a VisualForce page, use the apex:outputText tag.
<apex:outputText value="{0,date,MM/dd/yyyy}" title="Date Of Birth" >
<apex:param value="{!dateOfBirth}" />
</apex:outputText>

As you can see, the value attribute in the outputText tag defines to format of the date, and the actual value of the field is passed in the apex:param tag.
Comments

 

Add comment

Has this tutorial been helpful to you? Or do you see anything wrong? We appreciate your opinion!
Your comment:
Show formatting hints
HTML is disallowed, but in your text you can use the following markup
  • [code][/code] for a block of code
  • [tt][/tt] for inline code
  • [link]link href|link anchor[/link] for links
  • [b][/b] for bold text
Email:
+ Ask a question
If you have a technical question related to programming and computers, ask it here. Other users will help you solve it!
Unanswered questions
Share your knowledge by helping others solve their problems