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:
- 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)
- Tried to Use a DateAndTimeCell
Issue: but it needs a breakdown of information and doesn’t include Timezone.
- 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?
Are there any online sources where I can find examples for ZonedDateTimeCell implementation?
LocalDateTime ldt = LocalDateTime.of(2016, Month.AUGUST, 22, 14, 30);
final ZonedDateTime klDateTime = ldt.atZone(ZoneId.of(“CET”));
Now in the table
cells = 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.
To create such a cell you need to use its factory class.
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:
While appending the data row:
String mydate = “2020-02-20T15:52:05+01:00[CET]”;
cells[i] = ZonedDateTimeCellFactory.create( mydate );