How to pass a Date object to JDBC adapter without changing the format of the date.

Hello Team,

I am actually facing an issue to pass a java date object to my JDBC adapter service.

I have a date string as such 2012/08/17 11:08:02.102 AM. When I conver it to a java date object I am getting the below 2012/08/17 11:08:02 CAT using the method wm.tn.util:stringToDate. I would like my date object to be the same format as the date string when passing it to the jdbc adapter service.

Does anyone knows how to do this or can just help me on that?

Thanking you in advance.

Kind Regards,
kolo

When you see "2012/08/17 11:08:02 CAT", it’s just a readable view of the java.util.Date object. As an object, it has to be re-format (basically a conversion into a String with a default pattern) in a way you can understand it.

Assuming you try to insert a java Date into a DATE-type column, you just have to set the input of your jdbc adapter service to “java.util.Date” and map your object.

Hello Arnaud,

Thanks for your reply. I have tested this also but the value written to the database is the only the date with a fixed time like 2012/08/17 12:00:00 AM.

All my records are written to the table with the same time value. Please see attached image, my dateString after I convert it to date object. I can see in the pipeline the value of the date object which I will pass to my JDBC adapter is as such "2012/08/17 11:08:02 CAT" as the date is being written but the time is default 12:00:00 AM.

Do you know how can I fixed this?

Thanking you in advance.

Kind Regards,
kolo
date.jpg

Do a search for SQL date data type to find information. Basically, a SQL date does not have a time component–and the Oracle JDBC driver is more or less enforcing this.

The wM and Oracle docs will describe the variety of things you can do to store the time portion.