Hello!
I am losing my mind with some timezone issues… I am trying to find the code to set a date variable to midnight (00:00) on the current day. I am located in the EST timezone but the only thing that I can get is UTC! I ran the following code at 7:54 and it returned 00:00 for the next day because UTC was already in the net day. I hsve included a few lines of code below and what they return. I am hoping that they would return, Mon Nov 12 00:00:00 EST 2018.
def now = new Date()
7:54:43 PM: trace now = Tue Nov 13 00:54:43 UTC 2018
def midnight = new Date().clearTime()
7:54:43 PM: trace midnight = Tue Nov 13 00:00:00 UTC 2018
log.debug “The time zone for this location is: ${location.timeZone}”
7:54:43 PM: debug The time zone for this location is: sun.util.calendar.ZoneInfo[id=“America/New_York”,offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
def startTime = timeToday(“00:00”, location.timeZone)
log.trace “startTime = $startTime”
7:54:43 PM: trace startTime = Mon Nov 12 05:00:00 UTC 2018
Any help would be VERY appreciated!
Thank you!
Matt