The below code is throwing error

   Line 2931: Xmlstreamwriter.writeCharacters((Account.Date_From__c==null)?'':Account.Date_From__c.format('MM/dd/yyyy hh:mm a'));

Compile Error: Method does not exist or incorrect signature: void format(String) from the type Date at line 2,931 column 115

I tried Changing it to Account.Date_From__c.format('EEEE'), but didn't work

1 Answer 1


Date does not have a format() method accepting a string. That method is available only on DateTime. You can create a DateTime from a Date and simply use a format string that does not include time-based components:

DateTime.newInstance(myDate.year(), myDate.month(), myDate.day()).format('MY_FORMAT_STRING');

There's a number of Ideas out there you can vote on, although the point totals suggest they'll never be looked at: one and two (mine).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.