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

add a year in apex
This is a ridiculously simple question and just involves date formatting. Hoping one of the brains on here can figure this out before I do.
I just want to add 1 year to the current year.
So if I've got
DateTime dt=System.now();
String str=dt.format('yyyy');
I just want to add 1 year to that string, so I can refer to it in my code. That's it.
This has got to be super easy I just am too dumb to see it yet.
Thanks guys
Hi,
You can use addYears() method of DataTime.
DateTime newDate = System.Now().addYears(1);
DateTime Methods documentation:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm
Hope this helps :)
Thanks,
Devendra