COnverting java.lang.string to java.sql.timestamp

Hi Forum,

I need to write a java service where java.lang.string needs to be converted to java.sql.timestamp.

Need to do two things:

1.Change the “Input Field Type” of DATE column from java.lang.String to java.sql.timestamp in the adapter service
2.Converting date string to a java.sql.timestamp object prior to invoking the adapter service""

[SIZE=2]
Please mail me at parvati.preeta@gmail.com

or kindly reply to the post

Thanks,
Preeta
[/SIZE]

in java code, you can use: java.text.SimpleDateFormat

SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss.SSS”);

Timestamp sqlTime= new Timestamp(sdf.parse(TheTimeString));

Thanks alot for ur reply…

Timestamp sqlTime= new Timestamp(sdf.parse(TheTimeString));

== www.solitaire-champ.com ==

Hi,

you can use the built-in service “formatDate”. you need to map the date and date pattern.

Regards,
Naga.

Hi,

if the build in service “pub.date:formatDate” is not available in WmPublic package,
you might want to have look at the WmTransformationServices package or the PSUtilities packagae (both available from the download section of the community).

At least one of them contains a service your are looking for.

Remember to change the input field of your Adapter Service to java.util.Date instead of java.lang.String or java.sql.Timestamp. It will be automatically mapped to Database datatype TIMESTAMP by the Adapter.

Regards,
Holger

Looks like a old post, but pub.date:formatDate exists in WmPublic. I am on v98, I just used it today :slight_smile:

Hi,

if the WmPublic service is available it is always preferrable to use this one.
But this does not change the output type:
It is java.util.Date, not java.sql.Timestamp.

Indeed this seems to be an older post from 2012.
I got irritated by latest update Waleed.

Even by updating older posts with current possibilities this might help the community members to learn about improvements which have been made to code base over time.

Regards,
Holger

I agree with you.

So I could use some help. I am new to Webmethods and have been trying to fix an issue for sometime.

Maybe if you guys had some i/p that would help

This is the DB table
Name Null Type


EVENT_ID NOT NULL NUMBER(20)
SOURCE VARCHAR2(20)
TARGET VARCHAR2(25)
EVENT_DATE DATE

I am now trying to use the JDBC adapter to insert a row, I have problems with the date column when specifying the input object as a string. See attached image.
I read through some of the posts and tried to use the to_date function, passing in the string a i/p.

However I still get the following.

com.wm.pkg.art.error.DetailedServiceException: [ART.117.4002] Adapter Runtime (Adapter Service): Unable to invoke adapter service ServerLogTest.database:insertIntoEvents.
IllegalArgument Exception for field: EventE. Error: java.lang.IllegalArgumentException

I wonder if these is a service for string to java.sql.date conversion