Question

I've been struggling to set the Time zone inside a GroovyScript. By now I have found out that the following code returns the actual time stamp from my location.

javax.xml.datatype.DatatypeFactory.newInstance()
                                  .newXMLGregorianCalendar( GregorianCalendar.getInstance() ).toString()[0..21] + "Z"

Now I need it to return the date and time in UTC specifically, so it has the main server's timezone and could be run from any other location.

All these are run in a GroovyScript test step in SoapUi and it will be used as a variable inside a WSDL request.

Note: This will be used as a single liner in the Custom Properties of a Soap Project.

No correct solution

OTHER TIPS

One of the solution:

System.setProperty('user.timezone', 'UTC')

def gc= new GregorianCalendar()

the second is:

c = Calendar.instance

c.timeZone = TimeZone.getTimeZone("UTC")

The first solution work with a GregorianCalanedar which easy to convert to xml date. But I think best solution work with Calendar.

I don't test these codes! Please check it!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top