Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

date calculation

Thread view: 
Brandon McCombs - 12 May 2006 05:17 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
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.