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
Guru RamGuru Ram 

change date format mm/dd/yyyy to dd/mm/yyyy in apex class

Hi Guru,
Here is the piece of code that will help you convert your date "mm/dd/yyyy" to "dd-MM-yyyy" format in apex class.
DateTime yourDate =;
String dateOutput = yourDate.format('dd-MM-yyyy');
System.debug('Debug: '+dateOutput);
I hope it will you.
Nguyen TranNguyen Tran
The OP asked for Date format, not DateTime. My suggestion is convert Date to DateTime and then use format(stringFormat) from DateTime.