In my code, I am writing a query where I can give start date as midnight of some date.
So, I have written like below :
DateTime startofDate = DateTime.newInstance(dummyObj.StartDateA__c,Time.newInstance(24, 0, 0,0));
// dummyObj.StartDateA__c
is a date field.
I checked in debug log it is coming like below :
CreatedDate >= 2014-04-01T12:00:00Z
So, my question is what'd be the value of Time.newInstance method, so that it will consider the time starting from midnight.
Attribution to: SFDC Geek
Possible Suggestion/Solution #1
The answer to your question depends on which timezone you are in .The debug logs will always show time in GMT and the method DateTime.newInstance always returns constructed date time in your local time zone .
So I believe its calculating GMT equivalent of local date and time constructed from your expression .
Also below two expressions are same in case thats causing confusion
system.debug('*****'+Time.newInstance(0, 0, 0,0));//*****00:00:00.000Z
system.debug('*****'+Time.newInstance(24, 0, 0,0));//*****00:00:00.000Z
Attribution to: Mohith Shrivastava
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/32018