Visualforce Date formatting

  • I need this date format in a visualforce page: "December 14, 2013". I can't seem to find the format options for visualforce. I read that it's the same as the java messageformat class options, but I cannot find a list for that either.

    A little help would be much appreciated

    Look at the JavaDocs for SimpleDateFormat for the various date formats.

    Good link Peter. Ive updated my answer with it.

  • BarCotter

    BarCotter Correct answer

    8 years ago

    This will print the date out in the format December 14, 2013. The documentation can be found here

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

    or if all you need is the current date printed out in that format then you can use this:

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

    Have a look at the JavaDocs for SimpleDateFormat for the various date formats. (Thanks to @PeterKnolle for the correct link)

    Perfect, thank you

    When a date is being passed to the param, how is that transformed? The docs for `apex:param` say only strings, numbers, and booleans can be used. How is the date transformed into one of those values? I'm assuming it's miliseconds since Jan 1, 1970

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM