N_P
(N P)
June 16, 2020, 9:27pm
1
Hi Folks,
I am trying to make a scripted field that takes the "@timestamp " field converts it to PST (pacific standard time) and then extracts the hour.
Can anyone see where I am going wrong with the below scripted field?
String datetime = doc['@timestamp'].value;
ZonedDateTime utc = ZonedDateTime.parse(datetime);
ZonedDateTime pst = utc.withZoneSameInstant(ZoneId.of('America/Los_Angeles'));
return pst.getHour();
matw
(Matthias Wilhelm)
June 18, 2020, 7:38am
2
Hi
Here we go:
ZonedDateTime utc = doc['@timestamp'].value;
ZonedDateTime pst = utc.withZoneSameInstant(ZoneId.of('America/Los_Angeles'));
return pst.getHour();
You don't need to parse the value, it's already a ZonedDateTime
Best,
Matthias
system
(system)
Closed
July 16, 2020, 7:38am
3
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.