How to Get Date Time for Specific Timezone and Date in Specific Format
The below code for gets datetime for the New Zealand timezone. For more information on DateTime and available Timezones, please check our API.
def todayDateTime = new DateTime()
def nzTimeZone = api.getTimeZone("NZ")
def todayText = todayDateTime.withZone(nzTimeZone).toString("yyyy-MM-dd")Alternatively:
def date = new Date()
def offset = api.getTimeZone("NZ").getOffset(date)
def shiftedDate = new Date(date + offset)Found an issue in documentation? Write to us.