Create timestamp

What is the most efficent way to create a timestamp of the current time and append it as a new column?

If it is a java snippet, could you please give a code example?

Thanks.

Hi you can use this

 

Date dt = new Date();
SimpleDateFormat df = new SimpleDateFormat( "yyyy-MM-dd;HH:mm:ss.S" );
return  df.format( dt );

 

in the Java Snippet. With the Output String.

 

Afterwards. Use the String to Date/Time to get the Date and Time Cell.

Best, Iris

1 Like

Awesome thanks!

 

Not being a java person, the whole snippet concept is a little perplexing.

being an absolute ignorant in java makes it worse...Seamus5, can you post a screen shot of your java snipet dialog?

thx a lot

A good solution to this would be whether the KNIME guys can add an extra couple of lines into the "Extract System Properties" node output to include a current date and current time, as I also lack any knowledge of Java.

Simon.

1 Like

I would be most grateful if the author, seamus5, or someone would please post the configuration window for a Java Snippet or Java Edit Variable for this little bit of code: 

 

Date dt = new Date();
SimpleDateFormat df = new SimpleDateFormat( "yyyy-MM-dd;HH:mm:ss.S" );
return  df.format( dt );

 

The code given by Iris does not follow the Java Edit Variable conventions, and I'm not knowledgeable enough to figure out how to change it.

 

Much thanks,

Bill

Hi Bill,

yes the problem is that in the java edit variable you need to add

import java.text.SimpleDateFormat;

in your custom imports. I add you the screenshot of the configuration dialog :-)

Greetings from cloudy germany

Iris

 

PS: we are currently working on our time series support for 2.8.0

Did I just read 2.8.0? That's the summer release, isn't it? :-)

 

- E

Hi Iris,

Do you also consider adding time stamps for data importing nodes (or nodes using services) as properties? It might be an important information when the data was accessed (or ther service used) if there are multiple versions. I know, some of these nodes are not KNIME nodes, but this could be a good practice that might be suggested, followed. (I am not sure how loops handle properties, so maybe this is not an ideal solution. Maybe flow variables would be better? Or properties with custom keys?)

Cheers, gabor

Iris,

 

Thank you so much.  This is perfect.

 

My goal is to set up a loop in Knime that runs a database read as often as possible for 23 hours and 50 minutes.  Then at the appropriate time, the loop stops and a special nightly calculation is run all from inside the same workflow.  Then, the 23:50 loop starts up again.

 

So I am looking forward to any date-time manipulation tools that might be included in Knime 2.8!

 

All the best,

Bill

All,

 

As a frequent date/time user I've come across the occasional bug (a classic one being "date only" fields being interpreted as date/time stamps at 00:00:00,0, and thus to belong to the previous day) and missing features (ISO weeks, anyone?) in KNIME. Some of these issues seem to be owed to poor date/time handling in Java in general - but seems there's a library for that: JODA.

 

Any chance this will eventually become a default library in KNIME? Any chance we get ISO weeks in the date field node as well? :-)

 

KTHXBYE! :P
E

1 Like

We are making progress and are currently looking in JODA as well (thanks for the pointer). JODA will be available with Java8 (see JCP-310) and we considering this as a new integration towards better date/time handling. In the meantime, we will improve the time series integration to support timezones - which will solve most of these problems already.

1 Like