Unix timestamps in Talend Open Studio

Today (while migrating the userdata for dracoblue.net) I was facing the issue, that I needed to transform the unix timestmaps (used by SimpleMachinesForum) into date-objects.

After trying different things, I noticed that the easiest way is the java-function to create a new Date-Object.

Converting UnixTimestamp (int/long) to Date:

new java.sql.Timestamp(new Long(row1.registerDate)*1000)

Explanation: Since the Timestamp expects milliseconds since 01/01/1970, but I have seconds, I need to multiply be 1000. But since the initial Value may be a int, which can't be that big we need to convert it to Long first.

Converting Date String (e.g. dd.MM.yyyy) to UnixTimestamp:


Converting Date Object to UnixTimestamp:

In java, open source, talend by
@ 15 Feb 2009, Comments at Reddit & Hackernews