Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How correct convert from Decimal with E to float in Apache NiFi ?

avatar
New Contributor

Hello,
I suppose that my problem is very simple.
I have a problem with correct convert from Decimal to float in NiFi. I have an attribute originalTime with value
2.0160408003959164E13
When i use UpdateAttributeProcessor and then I write ${original:toNumber()}
I get value like this:
20160408003959
I know that correct format is:
20160408003959.166
How is method of correct conversion and how properly get .166?

1 REPLY 1

avatar
New Contributor

Ok. I found a simple solution to convert Scientific Notation To Decimal Notation.

I used ExecuteScript processor and i writed a simple script in JavaScript .

The code is below:

var flowFile = session.get();
if (flowFile != null) {
        var date = flowFile.getAttribute('date');
        var valueDate= Number(date);
        flowFile = session.putAttribute(flowFile, 'date', valueDate);
}
session.transfer(flowFile, REL_SUCCESS)