Patch for DB2 time format

59 views
Skip to first unread message

Niklas Mehner

unread,
Apr 17, 2016, 5:53:56 AM4/17/16
to H2 Database
Hi there,

DB2 uses the time format hh.mm.ss ( https://www.ibm.com/support/knowledgecenter/SSEPEK_10.0.0/com.ibm.db2z10.doc.intro/src/tpc/db2z_datetimetimestamp.dita ). Currently this causes an exception DateTimeUtils.parseTimeNanos.

Is it possible to include the attached patch in H2 to support the hh.mm.ss format as an alternative? Currently I do not see an option to limit this to the DB2 compatibility mode.

best regards,
  Niklas
DB2_Timeformat.patch

Noel Grandin

unread,
Apr 17, 2016, 6:55:39 AM4/17/16
to h2-da...@googlegroups.com
Mostly fine thanks, but I'd prefer that you patched the Mode class to add another boolean option for this

Niklas Mehner

unread,
Apr 17, 2016, 1:20:39 PM4/17/16
to H2 Database
The problem in this is getting the mode. I could pass it in, but the calling class (ValueTime) does not know about the mode either. Adding a mode parameter to ValueTime.parse leads to requiring a mode in Value.convertTo().
And this leads to nearly every method of Value requiring a mode parameter (which makes the interface messy) or having a mode field in every Value instance (which might have some performance/memory impacts).

Do you see a better approach for this?

Noel Grandin

unread,
Apr 18, 2016, 3:58:25 AM4/18/16
to h2-da...@googlegroups.com
Good point, I'll commit this as is. Since you plan to contribute more than trivial amounts of code, could I get a
license statement please?

See here:
http://h2database.com/html/build.html#providing_patches

Thanks, Noel

Thomas Mueller

unread,
Apr 19, 2016, 12:40:47 AM4/19/16
to h2-da...@googlegroups.com
Hi,

(I didn't read the patch yet). Using the SysProperties class would be good (enabled by default I guess), so that the feature can be disabled in case of problems.

Regards,
Thomas
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Niklas Mehner

unread,
Apr 19, 2016, 2:08:53 AM4/19/16
to h2-da...@googlegroups.com
Hi Thomas,

I don't think this should cause any problems, since it only tries to parse the date the DB2 way, if parsing the "normal" way fails. So it will only accept more date strings as valid. Short of using the database for date validation I cannot think of a way this will cause a change of bahavior for anyone.

best regards,
  Niklas
 

--
You received this message because you are subscribed to a topic in the Google Groups "H2 Database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/h2-database/Y8k47RJADJE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to h2-database...@googlegroups.com.

Niklas Mehner

unread,
Apr 19, 2016, 2:10:49 AM4/19/16
to h2-da...@googlegroups.com
I wrote the code, it's mine, and I'm contributing it to H2 for distribution multiple-licensed under the MPL 2.0, and the EPL 1.0 (http://h2database.com/html/license.html).

This statement is valid for all the code I am/will be contributing.

Best regards,
  Niklas


Reply all
Reply to author
Forward
0 new messages