Hex to BigInteger or Double

Hi all,

I’m using KNIME round about one year and I’m very happy about it.
Currently I’ve searched the forum up and down but I didn’t find a solution that works for me. I have hex numbers in a column with 8 digits. This hex numbers i have to convert in long or big integer. I found a topic with a Java Snippet (simple) with this command line: return Integer.parseInt($column1$, 16); thx at @johannes.schweig
In his example it works with two digit hex numbers. In my case the hex number will be a UNIX time string when converted. Is there maybe a way to convert this in one step? Have anybody an idea?

Greetings, Babbi

Try with:

new Date(Long.parseLong($column1$, 16))

Hello pigreco,

I get this error message

Ok. You cannot return a Date with Simple Java Snippet node.
THe error is caused by the incompatibility between Date type returned by code and return type setted in mask (Long).
If you want create a Date in single node you have to use Java Snippet Node (not simple) and create an output var of Date type.

1 Like

Hi pigreco,

sorry I’m a noob to Java. I tryed this but the Java Snipped throws this exception
java.lang.NullPointerException
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at JSnippet.snippet(JSnippet.java:33)
at org.knime.base.node.jsnippet.JavaSnippetCellFactory.getCells(JavaSnippetCellFactory.java:300)
at org.knime.core.data.container.RearrangeColumnsTable.calcNewCellsForRow(RearrangeColumnsTable.java:541)
at org.knime.core.data.container.RearrangeColumnsTable.calcNewColsSynchronously(RearrangeColumnsTable.java:462)
at org.knime.core.data.container.RearrangeColumnsTable.create(RearrangeColumnsTable.java:380)
at org.knime.core.node.ExecutionContext.createColumnRearrangeTable(ExecutionContext.java:385)
at org.knime.base.node.jsnippet.JavaSnippet.execute(JavaSnippet.java:1015)
at org.knime.base.node.jsnippet.JavaSnippetNodeModel.execute(JavaSnippetNodeModel.java:139)
at org.knime.core.node.NodeModel.execute(NodeModel.java:737)
at org.knime.core.node.NodeModel.executeModel(NodeModel.java:571)
at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1236)
at org.knime.core.node.Node.execute(Node.java:1016)
at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:557)
at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:95)
at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:218)
at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:124)
at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:334)
at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:210)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)
2020-05-12 21:35:13,358 : WARN : KNIME-Worker-5-Java Snippet 0:21 : : Node : Java Snippet : 0:21 : Exceptions in the code caused missing rows to be output.

My “code” look like this

I think this is error 80 (sitting 80cm bevor the monitor :slight_smile:)

Do you have any missing value? The exception is raised because there is a row where Col4 is Null or empty string.
Is this an expected data?

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