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
NjangaNjanga 

Date Formating

Hi guys,

am getting date in this format.

this is sample date:  Thu Aug 09 00:00:00 GMT 2012

how do i format it as 23/09/2012

 

Thank you!.

Ulas KutukUlas Kutuk

If you can use a ouputfield, it will be displayed automatically just like your example,

But if you are using a outputtext you an use like this

<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
       <apex:param value="{!YOURDATEVARAIBLE}"/>
</apex:outputText>

 

NjangaNjanga

 

Thank you for quick reply,

Let me rephrase my problem again.

I have a date as a string. This is my String

 

String myDateTime = "Thu Aug 09 00:00:00 GMT 2012".  in my apex class.

 

What i wanted is to format this date to something like 23/09/2012.

Ulas KutukUlas Kutuk

Let us cast your string as date than you can use in to Visualforce just like first post,

Date myDate = date.valueOf(YourStringDateTime);

 Now use mydate in VF like:

 

<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
       <apex:param value="{!myDate}"/>
</apex:outputText>