I want to know how can I capture the system date using a java program. I want to run this code automatically when the system is login. I want to capture the system date even if the user change the system date.
Kindly waiting for your suggestions

Thanking You

ever heard of the Date class? Or the Calendar class?

Directly from the API doc for Calendar class...

Like other locale-sensitive classes, Calendar provides a class method, getInstance, for getting a generally useful object of this type. Calendar's getInstance method returns a Calendar object whose calendar fields have been initialized with the current date and time: Calendar rightNow = Calendar.getInstance();

I didn't get u. Can u explain detail.

just read the api's on Date or Calendar. Or look for "system date + java" in google, you should find all you need

just use this single line

Date thedate=new Date();

and print it....


Simply you should construct a date object and add it in the method main


thnak you all.

I want to run this program automaticaly. That means if the system is login then this program execute and when the system is shutting down this program want to run again.