Hi!
Using WM JDBC Adapter with Oracle thin driver connecting to a table X. Inserting column Y that is of type date. What is a good way to convert my string date before I map it to the Insert Operation field of Date (BrokerDate)? Just a beginner with JAVA. Thanks in advance
IMO the best approach would be to create something that is reusable. In this case I have created a Common Operation under Adapters (in the Enterprise Integrator).
The operation has input that is date format (i.e. the format of the date that is in the string value, according to the symbols for the java.text.SimpleDateFormat object) and the string itself.
Then you need one custom step that takes the same parameters and return a date.
Add in the code below to the custom step, and then assign the returned date as the output from the Common Operation. Now anytime you want to do a conversion from a string to a date, you can just add an operation step into your integration.
If it still sounds confusing I can just send you my implementation if you want.
// create a date formatter
SimpleDateFormat formatter = new SimpleDateFormat( javaSimpleDateFormat );
Date convertedDate = null;
try
{
// return the string as a date
convertedDate = formatter.parse( dateTime );
}
catch (ParseException e)
{
throw new RuntimeException (e.toString());
}
return new BrokerDate (convertedDate);
Hi David,
If you don’t want to code with Java, you can use a custom SQL (one record)operation in EAI using TO_DATE like
${sql}select to_date(‘${HIRE_DATE}’,
‘DD-MMM-YYYY’)and specify HIRE_DATE as Unicode string in the input tab and HIRE_DATE as Date in the Output tab. Then from your component call this operation (you have to do the mapping between the two fields HIRE_DATE) before your INSERT operation and map the DATE field to the Insert Operation field of Date (BrokerDate)? .
Also, don’t forget to check the Allow unset fields box in the component properties tab to be able to insert NULL dates.
Let me know if this helps.
Nour.