Service to convert String to Date

Hi,
I am integrating AS400 to Oracle. I am using WmDB package from AS400 to webMethods and JDBC adapter from webMethods to Oracle. My problem is, 3 fields which I extract from AS400 are String fields which contain date,for example hire_date etc., Now I have to insert this field into a date field on Oracle. Is there any service like String to Date in webMethods. I am using Integration Server/Developer 6.0.1 and Windows NT. Pls…help me…!!!
Thanks,
Lavanya

You may wish to look at pub.date folder in WmPublic Package. There are a few Java Services that may solve your problem.

All the best

You can create a java service to achieve this. The code is :

IDataCursor cursor = pipeline.getCursor();

String dateFormat = “MM/dd/yyyy”;
String dateString = null;

if(cursor.first(“dateString”))
{
dateString = (String)cursor.getValue();
}
else
{
throw new ServiceException(“Missing input ‘date’”);
}

if (cursor.first(“pattern”))
{
dateFormat = (String)cursor.getValue();
}

SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
Date date;
try
{
date = sdf.parse(dateString);
IDataUtil.put(cursor, “date”, date);
}
catch (ParseException pe)
{
throw new ServiceException(“Date '” + dateString +
“’ cannot be parsed using the format '” + dateFormat + “'”);
}
finally
{
cursor.destroy();
}

Adapter Service should do this for you. Initially we had the similar problem with JDBC Adpater. We got a fix from wM. So check the advantage site for this fix. While creating the Adpater service put input type as String and JDBC type as Date. We are passing the date in yyyy-MM-dd format and its updates the table w/o any error. There is no need to create the String to date before calling the Adapter Service.

Hope it helps.
Pankaj

Hey Rupinder and Pankaj,

Thanks abt that. It really worked both ways :slight_smile:
Thanks a lot…!!!

Lavanya

Hi Sudheer,
Actually I was looking for String to Date. In the pub.date folder we have Date to String but not String to Date. Rupinder and Pankaj’s replies really worked well.

Thanks,
Lavanya