hello folks,
I am accessing a windows server and retrieving the attribute "lastLogon" from a user via JNDI: what i get is this date format:
Sun Jan 30 01:00:00 CET 2007
but i would like to have this format:
30.01.2007
the attribute "lastLogon" and its value is set to a number like this:
12345671234567 these are all 100nanoseconds values that means
100 ns * 12345671234567 = 1234567123456700 ns / 1000 = 1234567123456,700 seconds etc.... so the static method
public static final Calendar hundertNanosAlsCalendar(
String timeZone,
String hundertNanos)
is giving this output from above:
Sun Jan 30 01:00:00 CET 2007
with the below class and its methods i do the 12345671234567 ns converting into the above date with the bad format.
how can i get a format like:
30.07.2007 for example . What need i to change in the below code to make it possible or maybe you know a Date methode which can do this ?
public static final Calendar hundertNanosAlsCalendar(
String timeZone,
String hundertNanos)
throws NumberFormatException {
// Angabe in Tage seit 01.01.1601 umrechnen, die am
// letzten Tag verstrichenen Sekunden ermitteln
BigInteger bHundertNanos = new BigInteger(hundertNanos);
BigInteger bSekunden = bHundertNanos.divide(ZEHN_HOCH_SIEBEN);
BigInteger bTage = bSekunden.divide(SEKUNDEN_PRO_TAG);
BigInteger bSekAmTag = bSekunden.mod(SEKUNDEN_PRO_TAG);
// Calenderobjekt fuer den 01.01.1601
// in der gewuenschten Zeitzone erstellen
Calendar cal = new GregorianCalendar(1601, Calendar.JANUARY, 1);
cal.setTimeZone(TimeZone.getTimeZone(timeZone));
// verstrichene Tage und Sekunden hinzuziehen
cal.add(Calendar.DAY_OF_YEAR, bTage.intValue());
cal.add(Calendar.SECOND, bSekAmTag.intValue());
return cal;
}
Here i call the static method:
Calendar zuletzt = AdTools.hundertNanosAlsCalendar("GMT", myfakedate);
myfakedate contains the 12345671234567 ns data which will be converted into a real date.
Any help would be much appreciated!