soapui - Handle DST in UTC time using Groovy -




i trying convert milliseconds time date-time (yyyy-mm-dd't'hh:mm:ss'z') format in utc.

def startdatetimenew = testcase.testsuite.project.getpropertyvalue("startdatetime").tolong() def startdate = new date(startdatetimenew).format("yyyy-mm-dd't'hh:mm:ss'z'", timezone.gettimezone('utc')); log.info startdate 

'startdatetime' value '1503478800000'

the output getting :-

tue aug 22 18:13:59 ist 2017:info:2017-08-23t09:00:00z 

but want handle dst in output :-

tue aug 22 18:13:59 ist 2017:info:2017-08-23t10:00:00z 

if you're on java 8, i'd highly recommend using new java.time api instead of java.util.date

import java.time.* import java.time.format.datetimeformatter  // converts millis zoneddatetime representation def currentzone = zoneid.systemdefault() // or whatever appropriate zone def startdate = zoneddatetime.ofinstant(instant.ofepochmilli(startdatetimelong), currentzone)  // format in utc def fmt = startdate.format(datetimeformatter.iso_offset_date_time.withzone(zoneid.of('utc'))) 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -

python - Read npy file directly from S3 StreamingBody -