Play Games

Search This Blog

Monday, December 21, 2020

Display date in MM/DD/YYYY format in apex salesforce - Salesforce Globe For You

 Display date in MM/DD/YYYY format in apex salesforce  - Salesforce Globe For You 

Solution: First convert date to dateTime field and then use format() to display in the required format.

Example:

Date dtTodayDate = System.Today();

Datetime dtTodayDateTime = datetime.newInstance(dtTodayDate.year(), dtTodayDate.month(),dtTodayDate.day());

string strDate = dtTodayDateTime.format('MM/dd/yyyy');

system.debug('Date in MM/DD/YYYY format:'+strDate);

Output:



No comments:

Post a Comment