Find your content:

Search form

You are here

Date Format not appearing correctly

if(invoiceSet[0].Date_Format__c == 'dd-mm-yyyy'){
         datenow ='dd-MM-yyyy');
    }else if(invoiceSet[0].Date_Format__c == 'MM-DD-yyyy'){
         datenow ='MM-DD-yyyy');
     else if(invoiceSet[0].Date_Format__c == 'MM/DD/yyyy'){
         datenow ='MM/DD/yyyy');

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

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

My Block Status

My Block Content