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
Meeta Khullar 5Meeta Khullar 5 

Date field output format issue

I have a 2 VF page, one is used to create the output based on the input that is provided by the user and the other one is to create the csv file. I have date field as the output. The problem that I'm having is the csv output looks something like this for the date field "Thu Jan 01 00:00:00 GMT 2015". I want it in the mm/dd/yyyy format. How can I do this, here is the code for the VF for creating the csv file

apex:page controller="RMSControllerTest"  contentType="application/vnd.ms-excel#ConsignmentSearchData.csv" cache="true" >Invoice Number,Invoice Line Name,Product Name, Product Line, Start Date, End Date, Recognized Revenue, Deferred Revenue, Total Amount, QAD Domian, Created Date
    <apex:repeat value="{!invoiceLines}" var="item">
        {!item.invoiceLine.invoice__r.name},{!item.invoiceLine.name},{!item.invoiceLine.Start_Date__c},{!item.invoiceLine.End_Date__c},{!item.recognizedRevenue},{!item.deferredRevenue},{!item.totalAmount},{!item.invoiceLine.CreatedDate}
    </apex:repeat>
   
</apex:page>

      
karthikeyan perumalkarthikeyan perumal
Hello 

use below Code, 
 
<apex:page controller="RMSControllerTest"  contentType="application/vnd.ms-excel#ConsignmentSearchData.csv" cache="true" >
Invoice Number,Invoice Line Name,Product Name, Product Line, Start Date, End Date, Recognized Revenue, Deferred Revenue, Total Amount, QAD Domian, Created Date
    <apex:repeat value="{!invoiceLines}" var="item">
        {!item.invoiceLine.invoice__r.name},{!item.invoiceLine.name},
		<apex:outputText value="{0, date, MM'-'dd'-'yyyy }">
        <apex:param value="{!item.invoiceLine.Start_Date__c}"/>
        </apex:outputText>
		,
		<apex:outputText value="{0, date, MM'-'dd'-'yyyy }">
        <apex:param value="{!item.invoiceLine.End_Date__c}"/>
        </apex:outputText>
		,{!item.recognizedRevenue},{!item.deferredRevenue},{!item.totalAmount},
		<apex:outputText value="{0, date, MM'-'dd'-'yyyy }">
        <apex:param value="{!item.invoiceLine.CreatedDate}"/>
        </apex:outputText>
		
    </apex:repeat>
   
</apex:page>

Hope this will help you, 

Mark Best ANSWER if its works for you. 

Thanks
karthik