Support Questions

Find answers, ask questions, and share your expertise

Converting Epoch to TimeStamp of specific TimeZone

avatar
Rising Star

I am trying to convert the epoch in milliseconds to TimeStamp of specific timezone.

I tried using "format" of nifi expression language as below in updateAttribute processor

${closed_epoch:format("yyyy", "GMT")}

But updateAttribute processor is showing error saying "unexpected token ','.

Is it the bug with Nifi expression language? and what is the timezone that Nifi uses by default when I try ${closed_epoch:format("yyyy")}?

Is there any other way to convert epoch to timestamp of specific timezone ?

2 REPLIES 2

avatar
Master Guru

What version of NiFi are you using? The timezone parameter was added in NiFi 1.2.0 / HDF 3.0 (NIFI-2908).

avatar
Master Guru

@Anil Reddy

In addition to Matt's answer if you want to know all supported Functions in Expression Language for your version of NiFi then click on Right Up Corner GlobalMenu Button

59400-globalmenu.png

And click on Help

59401-globalmenu-help.png

3.Then Click on Expression Language Guide

59402-expressionlanguage.png

on Right Side will shows up all the functions that are supported in your version of NiFi.

If you want to implement ${closed_epoch:format("yyyy", "GMT")} this expression even though it is not supported in your version of NiFi then as a work around you can use plus,minus functions.

Assuming your closed_epoch attribute value is 1453843201123

${closed_epoch:minus(86400000)} //this expression will minus 86,400,000 Milliseconds(i.e 24 hrs) from closed_epoch value.

New value for closed_epoch will be 1453756801123.

*if you are having DayLightSaving time then you need to change the milliseconds value in minus(or) plus function.


globalmenu.png