Monday, 21 October 2019

Date timeZone format conversion using Groovy script

There is a requirement to convert the current date to the Europe time Zone. Standard time format is UTC.

Script:

import java.util.TimeZone;

def curDateTime1 = "";
def tz = TimeZone.getTimeZone("Europe/Berlin")
def ts = new Date() 
curDateTime1 = (ts.format("yyyy-MM-dd'T'HH:mm:ss", timezone=tz))

println curDateTime1

Output:

2019-10-21T16:25:04







No comments:

Post a Comment