mapping interval to duration

67 views
Skip to first unread message

Roland M.

unread,
Jul 16, 2019, 5:24:06 AM7/16/19
to H2 Database
Hello,
how can I mapp an interval (hour to minute) to java.time.duration from a result set?

So, I have a column with data type  INTERVAL HOUR (3) TO MINUTE.

And now I want to mapp it into java.time.Duration when the ResultSet is processed

Something like:
ResultSet results = createStatement().executeQuery(SELECT overtime FROM table_x)

Duration x = results.get <- what I have to do here.
Duration x = (Duration) results.getObject(1) throws
org.h2.api.Interval cannot be cast to java.time.Duration

Thank yu for your help.

Roland

Evgenij Ryazanov

unread,
Jul 16, 2019, 5:29:42 AM7/16/19
to H2 Database
Hello.

You need to use
getObject(1, Duration.class);

Roland M.

unread,
Jul 16, 2019, 6:33:24 AM7/16/19
to H2 Database
Thank you very much for your quick response.
That is easy (if you know how :-))
Reply all
Reply to author
Forward
0 new messages