Get hour + min


(amin) #1

Hi guys,
when i want to get hour i use this scripted field
LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['@timestamp'].value.millis), ZoneId.of('Asia/Tehran')).getHour()

in the past i could get hour + ":" + min . i forgot what script i wrote.
i guess it was sth like that :
LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['@timestamp'].value.millis), ZoneId.of('Asia/Tehran')).getHour() + ":" + LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['@timestamp'].value.millis), ZoneId.of('Asia/Tehran')).getMin

but it doesn't work for me. can anyone help me ?


(amin) #2

https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html
getMinute() is the answr ....


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.