I am creating the CSV using the batch code. Here is the code
Date testDate = 07/08/2020;
String monthOfTheDate = testDate.month()+'';
String dayOfTheDate = testDate.day()+'';
Integer monthSize = monthOfTheDate.length();
System.debug('Month size: '+monthSize );
Integer daySize = dayOfTheDate.length();
System.debug('Day size: '+daySize );
String formattedMonth ;
String formattedDay ;
if(monthSize == 1 || daySize == 1) {
formattedMonth = '0' +monthOfTheDate;
formattedDay = '0' +dayOfTheDate;
fileRow = fileRow +',"' +(formattedMonth + '-' + formattedDay + '-' + docDate.year())+'"';
}
else {
fileRow = fileRow +',"' +(docDate.month() + '-' + docDate.day() + '-' + docDate.year())+'"';
}
Actual result: 7/8/2020. Expected result: 07/08/2020
How I can achieve the expected result. Can anyone help me?
Thanks in Advance