Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using java format code in IDI for dates - help please!!

43 views
Skip to first unread message

michele

unread,
Sep 11, 2006, 12:07:20 PM9/11/06
to
Hi all

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

Eddie Hartman

unread,
Sep 12, 2006, 5:19:56 AM9/12/06
to
Hi Michele,

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

michele

unread,
Sep 12, 2006, 2:30:53 PM9/12/06
to
Hi Eddie
well it would if I knew how to do that. I have only created var types,
so I am unsure how to do this.

thanks
ever-so-stupid Michele

Eddie Hartman

unread,
Sep 13, 2006, 5:17:36 AM9/13/06
to
You should hear some of the questions I ask, 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

unread,
Sep 13, 2006, 9:36:09 AM9/13/06
to
Thank you!!

Michele

0 new messages