really stupid question and I hope it is a simple one to answer. I have
java and dB people here at work, but I am the only one using IDI - and
it is different.
I have a flat file that has a date field in it - format is
YYYYMMDDmmhhsssss
I need to plug this field into an Oracle dB TimeStamp field(DATETIME
java.sql.Timestamp) I have tried the following with no avail:
var formatter = new java.text.SimpleDateFormat("yyyy-MM-dd
HH:mm:ss.SSS");
ret.value = formatter.format(work.getString("date"));
12:05:29 BEGIN Iteration
12:05:29 what is date 20060828150251035
12:05:29 [AuditTrailUpdate] while mapping attribute "DATETIME"
java.lang.IllegalArgumentException: Cannot format given Object as a
Date
at java.text.DateFormat.format(DateFormat.java:291)
at java.text.Format.format(Format.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
at
org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:228)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1222)
at
org.mozilla.javascript.gen.c4.call(AuditTrailUpdate.AttributeMap.DATETIME:3)
at
org.mozilla.javascript.gen.c4.exec(AuditTrailUpdate.AttributeMap.DATETIME)
at com.ibm.di.server.AttributeMapping$SingleAttributeMap.eval(Unknown
Source)
at com.ibm.di.server.AttributeMapping.mapAttribute(Unknown Source)
at com.ibm.di.server.AttributeMapping.mapEntry(Unknown Source)
at com.ibm.di.server.AttributeMapping.mapEntry(Unknown Source)
at com.ibm.di.server.AssemblyLineComponent.add1(Unknown Source)
at com.ibm.di.server.AssemblyLineComponent.add(Unknown Source)
at com.ibm.di.server.AssemblyLine.msExecuteNextConnector(Unknown
Source)
at com.ibm.di.server.AssemblyLine.executeMainStep(Unknown Source)
at com.ibm.di.server.AssemblyLine.executeMainLoop(Unknown Source)
at com.ibm.di.server.AssemblyLine.executeMainLoop(Unknown Source)
at com.ibm.di.server.AssemblyLine.executeAL(Unknown Source)
at com.ibm.di.server.AssemblyLine.run(Unknown Source)
12:05:29 [AuditTrailUpdate] AddOnly
thanks in advance
michele mueller
boston college
I would suggest doing a Connect + Read next (from an Input or
Output Map in your JDBC Connector) to see what Java object
the Connector uses to return this column. I am guessing it
is a java.sql.Timestamp type.
Then try creating an object of this type and returning it
in your Att Map.
Hope this helps,
Eddie Hartman, IBM
www.tdi-users.org
thanks
ever-so-stupid Michele
Let's say you want a java.sql.Timestamp, then the first
thing to do is check out the JRE JavaDocs. Here we
see that there are a couple of ways of creating one
of these bad puppies: Either with year, month, date, hour...
and so on; or with a single milliseconds value.
Java rookie that I am, I had to play around a bit with
a Script in an AL to get this right
// Test date
var ds = "2006091313043201"
// Then use the handy UserFunctions method to get a java.util.Date
var dt = system.parseDate(ds, "yyyyMMddHHmmssSS");
// Finally, return the java.sql.Timestamp
ret.value = new java.sql.Timestamp(dt.getTime());
Hope this helps!
Michele