Does Salesforce have a bug in the day calculation logic if the hours is 00?
May 9th 2016 is a Monday. But Salesforce always returns Sunday. I guess when the hours is 00:00, its considering it as previous day?
Date currentDate = Date.newInstance(2016,5,9);
System.debug(currentDate);
System.debug(((DateTime)currentDate).format('EEE',String.valueOf(UserInfo.getTimeZone())));
The error mentioned above is consistent irrespective of whichever timezone I am in. I tried changing my User records Timezone values as well.
The date mentioned above is just an example. It holds true for any date.
Has someone noticed this ever or mine is a bad code? If so can someone correct me?
Also the Salesforce documentation says, for finding the start of the week, if its US based locale its Sunday and if its UK based locale its Monday. How do I determine which locales are US based and which are UK based? And is there any other type of locales apart from US and UK?
//This line returns me a Sunday if I set my locale to US
//and Monday if I set my locale to UK
currentDate.toStartOfWeek();