0

I am currently sending emails via Mandrill and SF sends dates like this:

2015-09-08 - How do I format the date to be in DD.MM.YYYY format.

At the moment I simply do: webinarLocale.StartDate

4

This example should work if you can use a string as the final output, otherwise dates are always displayed in the local context of the user...

Date d = date.today();
String dt = DateTime.newInstance(d.year(),d.month(),d.day()).format('d-MM-YYYY');
system.debug(logginglevel.error,dt);
| improve this answer | |
  • 2
    Is it two ds ? – Ali Gajani Sep 4 '15 at 13:02
  • 1
    @AliGajani - If you want a two digit day yes – Eric Sep 4 '15 at 15:14
  • How do I use dots instead of dashes though? – Ali Gajani Sep 4 '15 at 20:39
  • 1
    @AliGajani - Do you really need me to answer that? – Eric Sep 4 '15 at 21:53
  • 1
    No. I just replace dashes with dots :) – Ali Gajani Sep 4 '15 at 22:23
0

You can try this code :

Date dt = obj.Date__c;

system.debug(dt.day() + '.' + dt.month() + '.' + dt.year());
| improve this answer | |
  • This would not handle leading zeros. – Adrian Larson Sep 4 '15 at 14:24
  • That is right. I want leading 0s – Ali Gajani Sep 4 '15 at 20:55

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.