I have date field in UTC and want to convert that date in to a different timezone and display it.
I created a new runtime field and made the type as date, but when I convert the date and emit it, the displayed date is the original one and not according to timezone. Below is the script
String date = '2022-04-27T01:39:29.030+00:00'; ZonedDateTime time1 = ZonedDateTime.parse(date); Instant instant = time1.toInstant(); ZonedDateTime time2 = instant.atZone(ZoneId.of('America/Chicago')) ; long a = time2.toInstant().toEpochMilli(); emit(a);
The output I'm getting is the same date i.e 2022-04-27T01:39:29.030+00:00 but it should be something like this 2022-04-26T20:39:29.030-05:00[America/Chicago] according to timezone.
I'm not able to figure out what I'm doing wrong here.