You need to sign in to do that
Don't have an account?

Issue with Datetime().format() in Batch apex
String myDate = Datetime.now().addDays(14).formatGmt('MM/DD');
System.debug('mydate'+myDate);
Works fine when I execute from Developer console, today is 24 Jan and it prints 02/07 which is correct.
But when I execute in a Batch class it prints 02/38 which is wrong, why ?
The issue was formatGmt('MM/DD').
If you use formatGmt('MM/DD'), it will calculate through an year(till 365).
But to add just 14 days use formatGmt('MM/dd') (dd in small).
but still Thank you for the reply.
All Answers
Mark the answer as best if this solves your problem.
Thank You,
Muzammil Bajaria
The issue was formatGmt('MM/DD').
If you use formatGmt('MM/DD'), it will calculate through an year(till 365).
But to add just 14 days use formatGmt('MM/dd') (dd in small).
but still Thank you for the reply.