
Hi,
I have an issue with Date formating ifor the following dates 28-Dec-2014, 29-Dec-2014, 30-Dec-2014, 31-Dec-2014. Whenever I format one of these dates using either apex of Visualforce, a year is added to the formated date (31 Dec 2014 becomes 31 Dec 2015)
Other dates work fine.
This is really easy to reproduce using execute anonymous:
Date testDate = Date.newInstance(2014, 12, 31);
System.debug('Date.newInstance(2014, 12, 31) : ' + testDate);
System.debug('year : ' + testDate.year() + ' - month : ' + testDate.month() + ' - day : ' + testDate.day());
System.debug('Datetime.newInstance(testDate.year(), testDate.month(), testDate.day()) : ' + Datetime.newInstance(testDate.year(), testDate.month(), testDate.day()));
System.debug('Datetime.newInstance(testDate.year(), testDate.month(), testDate.day()).format("dd MMM YYYY") : ' + Datetime.newInstance(testDate.year(), testDate.month(), testDate.day()).format('dd MMM YYYY'));
The visualforce formating rendering the same is:
<apex:outputText value="{0, date, dd MMM YYYY}"><apex:param value="{!testDate}"/></apex:outputText>
Can someone please explain me what's going on?
Thanks
5 Antworten
I've never had a problem with the Apex Date or DateTime methods. Perhaps the forums at developer.salesforce.com can offer you more insight.
This Answers Community is focused on configuration and design questions. Programmatic questions are best submitted to
the developer forums at https://developer.salesforce.com where the forums and participants are geared toward programming troubleshooting and support.