function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ravi_SFDCRavi_SFDC 

Haing Date format Issue in APEX

Date.Today().MONTH()+'_'+Date.Today().Day()

From the above how can i get the first 3 letters of a month from the current date Date.Today().MONTH() (example: this should be as Nov, as this is Nov 3, 2016)

From the above how can i get the first 2 letters of the day from the current date Date.Today().Day() (example: This should be as 03, as today is Nov 3, 2016).

Can anyone provide their inputs to the code, which would be really helpful.


 

Best Answer chosen by Ravi_SFDC
Lalit Mistry 21Lalit Mistry 21
Below code should help
DateTime today = Date.Today();
String monthStr = today.format('MMM');
String dateStr = today.format('dd');
String yearSt = today.format('yyyy');

All Answers

Siva@51Siva@51
Hi Venkata_SFDC,

Try this,
 
DateTime today = Date.Today();
String d = today.format('MMM dd, yyyy');
System.debug('Date : '+d);

Thanks :)
Lalit Mistry 21Lalit Mistry 21
Below code should help
DateTime today = Date.Today();
String monthStr = today.format('MMM');
String dateStr = today.format('dd');
String yearSt = today.format('yyyy');
This was selected as the best answer