Quick Tip – Change Date format in Apex

If you use any date fields in Apex, it prints in this format

System.debug('Date: '+contact.Date);

Output:  2016-04-26 00:00:00

To change the format you can simply use: format()

System.debug('Date: '+contact.Date.format());

Output:  26/04/2016

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s