+ 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>