If you create a date (little d) object, it will contain the current system date & time. Then you can query the year, month, day, hours, etc. Here's the JavaDoc for one date/time class: GregorianCalendar There are also Date classes in java.util and java.sql. They have different query methods. Let's ask the rest of the gang how to choose which one to use.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Which to use depends on what you want to do with it. Mostly you should use java.util.Calendar (of which GregorianCalendar is a subclass, but this should be entirely transparent.) To get the current system date, use:
This will return a Calendar initialized to the current date/time for the Local that you are in (for most in the Western World, this will be an instance of the GregorianCalendar). Note that you cannot create a new Calendar directly. (new Calendar() is not permitted). You can do the same thing with a java.util.Date:
This, to, will return the current system time. The difference between Calendars and Dates is that Dates are conceptually immutable. (They used to be changeable, but this functionality was depricated in Java 1.2, I think) If you need to do date calculations, use Calendars. If you are storing the dates, use Dates (You can convert between the two through the Calendar's .getTime() and .setTime(Date ) methods). Note that java.sql.Date is a subclass of java.util.Date.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.