1

I am not able to format the Date of "Wed Jun 06 00:00:00 GMT 1990" to "DD/MM/YYYY"

i have written below code but it is giving error of method does not exist or incorrect signature

profile.Birthday__c is of Date type string

bufferdate=this.profile.Birthday__c.format('MM/DD/YYYY');

Can anyone help me with this

Regards, Keerthan Shetty

1
  • What is the profile here?
    – Saroj Bera
    Commented Jun 2, 2016 at 10:53

1 Answer 1

1

Two options (assuming bufferdate is a string):

1) if you org locale is the desired output:

bufferdate=this.profile.Birthday__c.format();

2) if not

Date d = this.profile.Birthday__c;
bufferdate = pad(d.month())+'/'+pad(d.day())+'/'+d.year();

private static String pad(Integer i){
     String s = String.valueOf(i);
     if(s.lenght() < 2) s = '0'+s;

     return s;
}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .