+ Start a Discussion
k practicek practice 

URGENT:How to display date as below Format?

Hi,
       Mu date is Date startdate="09/22/2015";

How to display This date as O/p:-2015-09-22  

please help me...
Grazitti TeamGrazitti Team
Hi,

You can format your date on VF page using outputText tag. For Example:

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


Please mark it as best if this helps you.

Regards,
Grazitti Team
www.grazitti.com
k practicek practice
I try to pass date through url but i was getting date as like "09/22/2015" but i want to pass O/p:-2015-09-22

help me..
Grazitti TeamGrazitti Team
Hi,

You have a variable in which date is stored for example that variable name is Date_To_Display. Use the following code on the VF page where you want to show the date in particular format. Just replace the variable with your own variable.
 
<apex:outputText value="{0, date, yyyy'-'MM'-'dd}">
    <apex:param value="{!Date_To_Display}" />
</apex:outputText>


Regards,
Grazitti Team
www.grazitti.com

 
k practicek practice
Hi,
         I don't want to display in an visualforce page .I want chanhe format using apex and pass through URL?
Grazitti TeamGrazitti Team
Hi,

Sample code for apex format is:

Datetime myDT = Datetime.now();
String myDate = myDT.format('yyyy-mm-dd');
system.debug(mydate);


Regards,
Grazitti Team
www.grazitti.com
 
k practicek practice
Its working but My Fied is Date field like public Date startdate{get;set;}
Grazitti TeamGrazitti Team
Hi,

Convert your date to datetime. For this refer to the following link:

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008kuMIAQ


Regards,
Grazitti Team
www.grazitti.com