Convert Date Format In apex salesforce

----------------------------------------------------------------------------------------------------------------------- 

Formula No. 1 

-----------------------------------------------------------------------------------------------------------------------

String crDate; 

dateTime d = logSheet.CreatedDate; 

crDate = (d == null) ? '-' : d.day()+ '/' + d.month() + '/' + d.year();

System.debug(crDate);

-----------------------------------------------------------------------------------------------------------------------

Formula No. 2

-----------------------------------------------------------------------------------------------------------------------

String crDate;

date d = logSheet.CreatedDate; 

crDate = (d == null) ? '-' : d.format('yyyy/MM/dd');

System.debug(crDate);

-----------------------------------------------------------------------------------------------------------------------



Comments

Popular posts from this blog

Custom List View Button In Salesforce

Get Record Id RecordId in LWC

PDF LWC (Link for pdf liabrary)