java.util.Date mismatch while insertion of a webMethods string variable into Oracle

Hi forum,

A few weeks back castropb has put up a sugestion in the thread [URL=“wmusers.com”]wmusers.com

in which he talked about

“1.[SIZE=2]Change the “Input Field Type” of your DATE column from java.lang.String to java.util.Date in the adapter service
2) Convert your date string to a java.util.Date object prior to invoking the adapter service”"

[SIZE=2]can anyone please tell me as to how do i go about doing this, as i am not sure webMethods is supporting this. If you can tell me a servie that does this i ll be grateful.

As of now i have a DATE column in the database and evey time i try to pass the paramater it says the input paramater not of type java.util.date…! Can anyone please advise.

Please mail me back on samriddhmangotra@gmail.com.

Thanks,
Sam
[/size][/SIZE]

webMethods is a company, not a product.

In Integration Server, one of the products licensed by webMethods, you can use pub.date:getCurrentDate to get a java.util.Date object that represents the current time. If you need a java.util.Date object that represents a time of your choosing, use WmTransformationServices:StringToDate.

Sam,

What I was suggesting on that thread is the creation of a simple Java service that takes two string variables as input, a date and a pattern. The Java service would then convert the date string into a Date object based on the pattern. This can be done via the java.text.SimpleDateFormat class.

I’m not familiar with the WmTransformationServices package, but it sounds like webMethods may have already created this service for you. Anyway, if you decide not to use their package for whatever reason, you can try something similar to the code below:

IDataCursor cursor = null;
try
{
   cursor = pipeline.getCursor();
   String dateStr = IDataUtil.getString( cursor, "dateStr" );
   String pattern = IDataUtil.getString( cursor, "pattern" );
   SimpleDateFormat format = new SimpleDateFormat( pattern );
   Date date = format.parse( dateStr );
   IDataUtil.put( cursor, "date", date );
}
catch( Throwable t )
{
   throw new ServiceException( t );
}
finally
{
   if( cursor != null )
   {
      cursor.destroy();
   }
}

This service would take 2 string variables as input (dateStr and pattern) and it would output an object variable (date). If you use this, be sure to import java.util.Date and java.text.SimpleDateFormat.

Also, be sure to analyze the other suggestions provided on that thread to see which one best fits your needs. There are other solutions that may be easier for you depending on what you’re most comfortable with.

  • Percio

thanks guys…! was able to do the same using the Transformation package as provided by webMethods.

thans a tonne again.

reg,
sam

hey sam can u please say me how u did it using transformations???.. that is from string to date as per my pattern.