function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfadm sfadmsfadm sfadm 

DateTime set to an hour earlier

I have an object of type Time startWorkingTime and object of type DateTime nextBusinessDay. I want to create new object of type DateTime based on startWorkingTime and nextBusinessDay.
Here is my code:
DateTime startWorkingTime = DateTime.newInstance(nextBusinessDay.year(), nextBusinessDay.month(),, currentStartHours.hour(), currentStartHours.minute(), currentStartHours.second());
After startworkingtime the time is set one hour earlier
For example:
23:59:24:025 USER_DEBUG [188]|DEBUG|currentStartHours 09:00:00.000Z
23:59:24:025 USER_DEBUG [189]|DEBUG|currentStartHours.hour() 9
23:59:24:025 USER_DEBUG [197]|DEBUG|startWorkingTime 2017-08-04 08:00:00
Could you please explain why the hour in startWorkingTime is 08:00:00 and advise how to fix it?

Best Answer chosen by sfadm sfadm
sfadm sfadmsfadm sfadm
I found a solution.
I had to use newInstanceGmt isntead.