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
Jessica Feauto 7Jessica Feauto 7 

Change all date formats to DD-Mon-YYYY

I want to change all date formats in Salesforce to DD-Mon-YYYY (example: 15-May-2020).  I know that I can change the Locale to change the date format, however, in most cases this shows up as 15-05-2020.   I also know I could probably write visualforce pages for each page a date occurs on, but that doesn't seem reasonable.

Is there a way to chagne all the date formats in the system with code (some sort of aura controller?)?
AbhishekAbhishek (Salesforce Developers) 
Hi Jessica,

Here is the piece of code that will help you convert your date "mm/dd/yyyy" to "dd-MM-yyyy" format in the apex class.


DateTime yourDate = Datetime.now();
String dateOutput = yourDate.format('dd-MM-yyyy');
System.debug('Debug: '+dateOutput);

Reference: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_date.htm

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks.


 
Nalini ch 6Nalini ch 6
Hello 

It looks like our team of experts can help you resolve this ticket. We have Salesforce global help-desk support and you can log a case and our Customer Success Agents will help you solve this issue. You can also speak to them on live chat. Click on the below link to contact our help-desk. Trust me it is a support service that we are offering for free!

https://jbshelpdesk.secure.force.com

Thanks,
Jarvis SFDC team