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
uzairuzair 

How to format date field value in visual force.

Hi all,

 

I have a problem with merging the date field into the visualforce page.

I used {!Oppr.Entry_Date__c} it displayed "Tue Aug 10 00:00:00 GMT 2010".

I require the format to be "Tue Aug 10 2010".

How to change the format to achieve my requirement.

Any help regarding this will be appreciated.

 

Thanks in Advance.

Best Answer chosen by Admin (Salesforce Developers) 
SSRS2SSRS2

Use following in your VF page;

 

 

<apex:outputText value="{0, date, EEE, MMMM d, yyyy}">
<apex:param value="{!Oppr.Entry_Date__c}"/>
</apex:outputText>

 

-Suresh

 

All Answers

RajaMohanRajaMohan

Hi Uzair,

 

You can achieve this by writing controller. Just do the following.

 

Controller:

    String eDate='';

public String getDate(){

    eDate=Oppr.Entry_Date__c.format('EEE, MMMM d, yyyy');

    return eDate;

}

 

and print in the VF page value="{!Date}".

uzairuzair

Hello RajaApex,

 

Thanks for your reply.

 

I received the following error message

"Error: Compile Error: Method does not exist or incorrect signature: [Date].format(String) ".

 

any help to overcome this error wiil be appreciated.

 

Thanks in Advance.

_Prasu__Prasu_

you will need to typecast Date into Datetime datatype.

 

Sample code:

 

Datetime d = system.now();
System.debug(d.format('EEE, MMM d, yy'));

 

 

SSRS2SSRS2

Use following in your VF page;

 

 

<apex:outputText value="{0, date, EEE, MMMM d, yyyy}">
<apex:param value="{!Oppr.Entry_Date__c}"/>
</apex:outputText>

 

-Suresh

 

This was selected as the best answer
uzairuzair

Thanks Prasanna it worked for me.

uzairuzair

thanks suresh,

 

it just worked for me as i'd required.

max_overloadmax_overload

Superb solution Suresh, thank you!