Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

convert the unix timestamp

Hello,
I  want to convert the unix timestamp  1443696342801  into date ,
i am new to Talend , i converted  1298226724 into date using  below logic , please see below attach screen shots:

But i am unable to convert this number 1443696342801  
any suggestion will be helpfull
its little urgent 
thanks
Amit
0683p000009MCtY.png
Labels (2)
18 Replies
Anonymous
Not applicable
Author

Hi,
Please try to use below expression in tMap:
new java.util.Date(row1.unixtimestamp)
Best regards
Sabrina
0683p000009MCkh.png
Anonymous
Not applicable
Author

Hi Sabrina,
I have situation regarding Milliseconds to Date Conversion.
There are 2 columns in excell sheet which contains only millisecond values and that have to convert into a Given Date format
Please take following table as Source table..
TRISTARTDATEDA    TRIENDDATEDA
1425148200             1423074600
1423074600             1482604200
Expected Outcome...
TRISTARTDATEDA    TRIENDDATEDA
01-03-2015             05-02-2015
05-02-2015             25-12-2016


Please kindly suggest me solution for this .
I am Waiting for positive reply
Anonymous
Not applicable
Author

new java.util.Date(row1.unixtimestamp) was the correct answer.
row1.unixtimestamp should be a long type. this will create the correct Date based on the Unix epoch.
Anonymous
Not applicable
Author

Hey,
Thanx for your reply but it doesnt seems to be working
it giving type casting error
Type Mismatch : Cannot convert from Long to Date
Type Mismatch : Cannot convert from Date to Long
My Source values are coming with Long Type and i put that logic you mentioned above in Target column and i give Date type to it
Is it Right?
Anonymous
Not applicable
Author

Hey,
Thanx for your reply but it doesnt seems to be working
it giving type casting error
Type Mismatch : Cannot convert from Long to Date
Type Mismatch : Cannot convert from Date to Long
My Source values are coming with Long Type and i put that logic you mentioned above in Target column and i give Date type to it
Is it Right?
Kindly find the uploaded image of mytMap.... 0683p000009MCtd.png
If i put long type in the target also then job runs but it gives wrong values like
17-01-1970
Anonymous
Not applicable
Author

Hi All,
Thanx for your reply's 
Fortunately i have done it by
0683p000009MCjU.png

0683p000009MCnd.png
Anonymous
Not applicable
Author

Hi,
Please try to use below expression in tMap:
new java.util.Date(row1.unixtimestamp)
Best regards
Sabrina

Hello Sabrina,
Thanks for your prompt reply,
I tried using your logic it seems to be working for  ex-1298226724
but when i want to convert  unixtimestamp 1443696342801 into date with timestamp i am getting error :invalid error
please check below error
Starting job unix at 22:38 09/01/2016.
connecting to socket on port 3771
connected
Exception in component tOracleOutput_1
java.lang.IllegalArgumentException: Invalid year value
at oracle.sql.TIMESTAMP.getOracleYear(TIMESTAMP.java:786)
at oracle.sql.DATE.toBytes(DATE.java:634)
at oracle.sql.DATE.toBytes(DATE.java:521)
at oracle.sql.DATE.<init>(DATE.java:116)
at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:9325)
at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:8954)
at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:9548)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:249)
at local_project.unix_0_1.unix.tOracleInput_1Process(unix.java:799)
at local_project.unix_0_1.unix.runJobInTOS(unix.java:1236)
at local_project.unix_0_1.unix.main(unix.java:1093)
disconnected
Job unix ended at 22:38 09/01/2016.
for your reference i am attaching the unix epoch converter output
10/1/2015, 1:45:42 PM 
i want the output as 10/1/2015, 13:45:42 in 24hrs clock
 
0683p000009MCqp.png
Anonymous
Not applicable
Author

Hi Sabrina & All,
Kindly attention Please 0683p000009MACn.png....
I have situation in one of ETL job.
i want to convert or remove special charterers from data
Please find Image attached, it has some special charecters and these may found in some of the data ,
so how could we handle this by ETL. There is one column Replace_By which has values that have to replaced by there respective Special Characters. and that particular row which has that  Special Character mentioned there have to stored in other file/table/tlogrow.
Please revert if you have any query regarding this.
. 0683p000009MCgD.png  
Anonymous
Not applicable
Author

Hi Shri_Kul1,
Here is a TalendHelpCenter:tReplace which carries out a Search & Replace operation in the input columns defined.
Best regards
Sabrina