I'm trying to create a command line based java application that parses
data returned from an active directory ldap query. The one attribute I
want returned is a field that keeps track of the last time someone
logged into a Windows domain. Active Directory keeps track of this time
stamp by incrementing a counter every 100 nanoseconds and is based off
of January 1 1601.
Does java have anything that lets me add one date to a period of time in
order to arrive at a 2nd date? For example I take 1/1/1601 and add a
number of days/hours/min/seconds to it (calculated from the attribute
from ADS) and I get a new date as a result? I've noticed the Date class
only starts counting at 1970 which might make what I want to do
impossible. Doing this task in Visual Basic scripting works well
(despite the 1601 base year) but there are other drawbacks that come
into play with that method.
thanks
zombie.squirrel - 12 May 2006 06:32 GMT
> I'm trying to create a command line based java application that parses
> data returned from an active directory ldap query. The one attribute I
[quoted text clipped - 13 lines]
>
> thanks
Brandon,
You can use the Calendar to add values to a date using the
java.util.Calendar add(int field, int amount).
Example to add twenty years:
Date d = someDate;
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.add(Calendar.YEAR, 20);
Date newDate = cal.getTime();
Hope this helps,
Zombie.Squirrel
Chris Uppal - 12 May 2006 09:03 GMT
> I've noticed the Date class
> only starts counting at 1970 which might make what I want to do
> impossible.
Just for interest: since the Date class wraps a time expressed in milliseconds
as a signed 64-bit long, it can cover the range:
B.C.E. 292269055-12-02 16:47:04.192
to
292278994-08-17 07:12:55.807
inclusive (times in UTC).
;-)
-- chris
Oliver Wong - 12 May 2006 16:20 GMT
>> I've noticed the Date class
>> only starts counting at 1970 which might make what I want to do
[quoted text clipped - 7 lines]
> 292278994-08-17 07:12:55.807
> inclusive (times in UTC).
I guess I better start storing water in my survival shelter for when the
Y292278995 bug comes along.
- Oliver