Article
Problem
I needed to convert the AD Attribute pwdLastSet from UTC time to a Java/SQL/DB2 format such as this: 20060425205130Z
I looked at the jadutils transformEpoch2FileTime and FileTimetoEpoch, but they don't do what I want.
Solution
I created my own Java class to convert it:
/*
* Utilities.java
*
* Created on September 14, 2006, 12:32 PM
*/
package com.acme.util;
import java.util.*;
import java.text.*;
/**
*
* @author e144717
*/
public class Utilities {
/** Creates a new instance of Utilities */
public Utilities() {
}
public static String fileTime2timestamp(String s)
{
long pwdSetDate = java.lang.Long.parseLong(s);
long timeAdjust=11644473600000L; // adjust factor for converting it
to java
Date pwdSet = new Date(pwdSetDate/10000-timeAdjust); //
DateFormat mydate = new SimpleDateFormat("yyyyMMddHHmmss");
return(mydate.format(pwdSet));
}
} Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 5261 reads


0