import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.util.TimeZone
// Get the current date and time in the default time zone
def currentDateTime = ZonedDateTime.now()
// List of time zones
def timeZones = TimeZone.getAvailableIDs()
// Format and print the current time in different time zones
timeZones.each { timeZoneId -(ganti dengan greater-than symbol)
def timeZone = TimeZone.getTimeZone(timeZoneId)
def zonedDateTime = currentDateTime.withZoneSameInstant(timeZone.toZoneId())
def formattedTime = zonedDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
println("Time in $timeZoneId: $formattedTime")
// Put the formatted time into JMeterVariables with a dynamic key
vars.put("formattedTime_${timeZoneId.replaceAll('[^a-zA-Z0-9]', '_')}", formattedTime)
}
tags : #dateandtime #jmeter #generator