I created a reusable transformation in which I have an input port of date/time format.
Now when I use this date/time port in my java code it gives me incompatible error long/date.
So I changed the input port of java transformation to String and used this string variable in java transformation. But even this code is giving me an error.
Severity Timestamp Node Thread Message Code Message
INFO 26-04-2016 16:55:30 node01_Gizmo READER_1_1_1 RR_4049 RR_4049 SQL Query issued to database : (Tue Apr 26 16:55:30 2016)
INFO 26-04-2016 16:55:30 node01_Gizmo READER_1_1_1 RR_4050 RR_4050 First row returned from database to reader : (Tue Apr 26 16:55:30 2016)
INFO 26-04-2016 16:55:30 node01_Gizmo READER_1_1_1 BLKR_16019 Read [10] rows, read [0] error rows for source table [CUSTOMERS] instance name [CUSTOMERS]
INFO 26-04-2016 16:55:30 node01_Gizmo READER_1_1_1 BLKR_16008 Reader run completed.
INFO 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JAVA PLUGIN_1762 [DEBUG] Unparseable using java.text.SimpleDateFormat@9586200
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JTX_1005 [ERROR] Column name [05/06/1998 00:00:00.000000] is invalid.
INFO 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JTX_1015 [DEBUG] Exception thrown from Java transformation: [Column name [05/06/1998 00:00:00.000000] is invalid.].
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JAVA PLUGIN_1762 [ERROR] Column name [05/06/1998 00:00:00.000000] is invalid.
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JAVA PLUGIN_1762 [ERROR] at com.informatica.powercenter.server.jtx.JTXPartitionDriverImplFixed.isNull(JTXPartitionDriverImplFixed.java:737)
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 JAVA PLUGIN_1762 [ERROR] at com.informatica.powercenter.server.jtx.JTXPartitionDriverImplGen.execute(JTXPartitionDriverImplGen.java:223)
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 TM_6085 A fatal error occurred at transformation [DateFormat], and the session is terminating.
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 TM_6085 A fatal error occurred at transformation [SQ_CUSTOMERS], and the session is terminating.
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 TM_6085 A fatal error occurred at transformation [SQ_CUSTOMERS], and the session is terminating.
ERROR 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 TM_6085 A fatal error occurred at transformation [SQ_CUSTOMERS], and the session is terminating.
DEBUG 26-04-2016 16:55:30 node01_Gizmo TRANSF_1_1_1 DBG_21511 TE: Fatal Transformation Error.
INFO 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8167 Start loading table [DateFormat] at: Tue Apr 26 16:55:30 2016
INFO 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8333 Rolling back all the targets due to fatal session error.
ERROR 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8170 Writer run terminated: Abort Session request received from the DTM
INFO 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8168 End loading table [DateFormat] at: Tue Apr 26 16:55:30 2016
INFO 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8035 Load complete time: Tue Apr 26 16:55:30 2016
LOAD SUMMARY
============
WRT_8036 Target: DateFormat (Instance Name: [DateFormat1])
WRT_8044 No data loaded for this target
INFO 26-04-2016 16:55:30 node01_Gizmo WRITER_1_*_1 WRT_8043 *****END LOAD SESSION*****
Day is an output port of type String. The below is the code used in java transformation:
SimpleDateFormat formatter;
formatter = new SimpleDateFormat("dd-MM-yyyy");
Date my_date = null;
try{
my_date = formatter.parse(Inp_Date);
}
catch(Exception e) {
System.out.println("Unparseable using " + formatter);
}
formatter = new SimpleDateFormat("d");
Day=formatter.format(my_date);
Please let me know how to use date/time variable in java transformation.
Regards, Dex.
You should use an expression transformation with the expression TO_CHAR(inp_Date,'dd')
to do such conversions.
In your Java code the format string (dd-MM-yyyy) does not match the input date format (05/06/1998 00:00:00.000000). It should probably be changed to something like this:
formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSSSSS");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.