I am at Australia and the time now is 13:00 Feb 1. With the following code:

DateTime thisTime = DateTime.now();
System.debug(thisTime.format('DD/MM/YYYY HH:mm'));

For the 2nd line I got 2016-01-01 03:22:04 which is correct. But for the 3rd line(the format one) I got 32/02/2016 + time. Is that a Salesforce bug? Any known issues or walkarounds?

  • I can't follow your example. Today is feb 2nd, but you say 01-01 is correct? Can you include the exact debug outputs, just to be sure? Feb 1, 2016 at 12:11
  • @Guy Sorry, typo, it should be 01-02
    – Lance Shi
    Feb 1, 2016 at 23:02

2 Answers 2


My fault. It should be dd/MM/YYYY instead of DD/MM/YYYY


But did you figure out what D (Capital D) mean?

Here is your answer

enter image description here

For more details



You must log in to answer this question.

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