문제

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.

올바른 솔루션이 없습니다

다른 팁

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!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top