You need to sign in to do that
Don't have an account?
JamesSS
How to get today date in apex class?
My input:
System.debug('Date.today();************ ' + date.today());
Output:
Date.today();************ 2013-06-07 00:00:00
expected output:
Date.today();************ 2013-06-07
Is possible to get my expected output?
System.debug('************ ' + system.today().format());
System.debug('************ ' + date.today().format());
Both will work like
************ 07/06/2013
************ 07/06/2013
All Answers
Thanks Gunish.
Please provide some example for that
System.debug('************ ' + system.today().format());
System.debug('************ ' + date.today().format());
Both will work like
************ 07/06/2013
************ 07/06/2013
DateTime todaysDate = System.today();
String todaysDateStr = todaysDate.format('yyyy-MM-dd');
System.debug(todaysDateStr);
Please mark this as best answer if this works for you.
use format method show only date.
Example:
System.debug(date.today().format());
date.today().format()
works, but it cannot take a format string :
date.today().format('yyyy-mm-dd')
causes "Method does not exist or incorrect signature: void format(String) from the type Date" .