Novell is now a part of Micro Focus

Converting AD Password Attribute from UTC to a Java Timestamp

Novell Cool Solutions: Tip
By Scott Kraemer

Digg This - Slashdot This

Posted: 27 Sep 2006


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.


I created my own Java class to convert it:

 * 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");

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates