Creating a Date, Time & Zone column knime table

Hi,

I’m on my way to implement a node which connects to REST and retrieves some data records. I need to implement a column that contains the date, time and timezone. I’ve tried 3 ways and faced a few issues. stating them below:

  1. Used a TimestampCell(column type) to retrieve the timestamp for each record in the table.
    Issue: Later cannot convert from timestamp to date&time column type because there is no node which accepts this format (Thu Jan 01 01:00:00 CET 1970)
  2. Tried to Use a DateAndTimeCell
    Issue: but it needs a breakdown of information and doesn’t include Timezone.
  3. Used formats that are accepted by knime “String to Date&Time”.
    Issue: It creates a string column which should again be processed by “String to Date&Time” node to convert the column type to “Date&Time”

Question: Is there any possible DataType for date time and timezone which I can directly use to create the table with the above-mentioned format?

Hi,
I think org.knime.core.data.time.zoneddatetime.ZonedDateTimeCell is what you need.
Kind regards
Alexander

1 Like

Hi,
Are there any online sources where I can find examples for ZonedDateTimeCell implementation?

My Code:
LocalDateTime ldt = LocalDateTime.of(2016, Month.AUGUST, 22, 14, 30);

final ZonedDateTime klDateTime = ldt.atZone(ZoneId.of(“CET”));

Now in the table
cells[0] = new ZonedDateTimeCell(klDateTime);

I get the error The constructor of ZonedDateTimeCell is not visible.
I’m importing the package(import org.knime.core.data.time.zoneddatetime.ZonedDateTimeCell;) and calling the constructor. The constructor here says “Package scope constructor, called from factory.” and I dont understand how to implement it.

Thanks in Advance.

Regards,
Laharika.

Hi,
To create such a cell you need to use its factory class.
Kind regards
Alexander

Hi,

Thank you very much. It worked.

Posting here with the example. Just in case if someone gets the same doubt. It might help.

Can create ZonedDateTime cell by using:

new DataColumnSpecCreator(“ZonedDateTime”,ZonedDateTimeCellFactory.TYPE).createSpec();

While appending the data row:

String mydate = “2020-02-20T15:52:05+01:00[CET]”;
cells[i] = ZonedDateTimeCellFactory.create( mydate );

3 Likes