
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how to convert a large number of nanoseconds into a date ???
Bonjour,
I have "Account-Expires" attribute from Microsoft LDAP (using talend tLDAPinput component) :
"The date when the account expires. This value represents the number of 100-nanosecond intervals since January 1, 1601 (UTC). A value of 0 or 0x7FFFFFFFFFFFFFFF (9223372036854775807) indicates that the account never expires."
It comes as a string.
Exemple : 130040605000000000
I'd like to convert it into a date "dd/MM/yyyy" .
Any idea ?
I tried with TalendDate.addDate("01/01/1601", "dd/MM/yyyy",Var.var3 ,"ss")
but Var.var3 has to be expressed as an integer ...
the string express buckets of 100 nanoseconds ... a second is 10^9 nano second.
so 130040605000000000 represent
13004060500 seconds since 01/01/1601
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This value is too large an integer in Java.
It must be included between -2147483648 and 2147483647.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Then, TalendDate.addDate("01/01/1601", "yyyy/MM/dd", n, "dd") where n is the number of days should gives the result but not sure (not tested) it works for dates before 1970/01/01 as this is the base (epoch) for Java.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bonjour,
Thank you for your answer.
Yes 13004060500 is the number of seconds ... but I have difficulties to manipulate it as an integer ...
using parseInt is rejected.
I will continue to test.
Thank you for your contribution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
using Integer.parseInt("13235158809")
java.lang.Exception: java.lang.NumberFormatException: For input string: "13235158809"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This value is too large an integer in Java.
It must be included between -2147483648 and 2147483647.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
as the "dates" in Microsoft Active Directory are expressed in buckets of 100 nanoseconds, I've started to suppress the last 7 caracters of the string. The result is supposed to be in seconds. What I need is to have a date, some converting in days is dividing seconds by 60x60x24=86400 ... so I suppressed 2 additional caracters in the string. Then, parseint is possible.
row6.accountExpires == null || row6.accountExpires.equals("0") || row6.accountExpires.equals("9223372036854775807") ? "0" : StringHandling.LEFT(row6.accountExpires, StringHandling.LEN( row6.accountExpires )-9 ) ==> Var.accountExpires
Integer.parseInt(Var.accountExpires) / 864 ==> accountExpiresint
Var.accountExpiresint == 0 ? "0" : TalendDate.addDate("01.01.1601", "dd.MM.yyyy", Var.accountExpiresint , "dd")
Thank you for your support TRF.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
