function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Will LylesWill Lyles 

How to format date objects in a visualforce page with column sorting

I am trying to format my date fields to a MM/dd/yyyy format.  I had this working until I had to use sorting in my VF page.  Now I can't figure out how to format the date and still retain the sorting feature I have on my page.

*****I was using something like this*****
<apex:outputText value="{0,date,MM/dd/yyyy}"> 
  <apex:param value="{!a.CreatedDate}" />
 </apex:outputText>


*****But had to switch to this for sorting*****
                <apex:column >
                    <apex:facet name="header">   
                        <apex:commandLink action="{!ViewData}" value="Created Date{!IF(sortExpression=='CreatedDate',IF(sortDirection='ASC','▼','▲'),'')}" id="CreatedDateSort">
                            <apex:param value="CreatedDate" name="column" assignTo="{!sortExpression}" ></apex:param>
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputLink value="/{!a.Id}" target="_blank">{!a.CreatedDate}</apex:outputLink>
                </apex:column>

**** My controller method *****
public PageReference ViewData()
    {
        //build the full sort expression
        string sortFullExp = sortExpression  + ' ' + sortDirection;

        //query the database based on the sort expression
        myCases = Database.query('SELECT ID, '
                                 + 'casenumber, '
                                 + 'subject, '
                                 + 'Severity__c, '
                                 + 'Case_Type__c, '
                                 + 'CreatedDate, '
                                 + 'ClosedDate, '
                                 + 'FROM Case  '
                                 + 'WHERE OwnerId= \'' + UserInfo.getUserID() + '\''
                                 + 'ORDER BY ' + sortFullExp + ' limit 1000');
        return null;
    }

It was suggested that I create some type of wrapper, but I don't know how to do this.  Has anyone done something like this before?