if(invoiceSet[0].Date_Format__c == 'dd-mm-yyyy'){
datenow = DateTime.now().format('dd-MM-yyyy');
}else if(invoiceSet[0].Date_Format__c == 'MM-DD-yyyy'){
datenow = DateTime.now().format('MM-DD-yyyy');
}
else if(invoiceSet[0].Date_Format__c == 'MM/DD/yyyy'){
datenow = DateTime.now().format('MM/DD/yyyy');
}
}
system.debug('dateeee'+datenoe);
in debug for first condition it is showing correctly as 11-12-2012 and in the second condition it is taking in 365 days format & displaying as 12-327-2012.But I want the normal format.How can i do it
Attribution to: Eagerin Sf
Possible Suggestion/Solution #1
Date format Strings are case sensitive http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html
DD is day in the year
dd is day in the month
So use dd as you have in the first instance.
Attribution to: techtrekker
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4698