Have a look at the java.util.Calendar class. First, you need an instance of Calendar: Calendar cal = Calendar.getInstance(); Then, you use the get method. Use one of the constants from Calendar for the parameter. For example: cal.get(Calendar.DATE); Hope this works, -Stu
Joined: Jul 01, 2002
thank you for the help, it workdes. But i still can't understand why i couldn't do it that way
A good place to look for an explanation of why and how a class functions is in The Java 2 API Documentation. The java.util.Date Documentation does not say that the class Date is deprecated, but many of its methods (and constructors) are deprecated. The first two paragraphs of the documentation for Date describe what the class should be used for and why many of its methods have been deprecated:
The class Date represents a specific instant in time, with millisecond precision. Prior to JDK 1.1, the class Date had two additional functions. It allowed the interpretation of dates as year, month, day, hour, minute, and second values. It also allowed the formatting and parsing of date strings. Unfortunately, the API for these functions was not amenable to internationalization. As of JDK 1.1, the Calendar class should be used to convert between dates and time fields and the DateFormat class should be used to format and parse date strings. The corresponding methods in Date are deprecated.
[ July 02, 2002: Message edited by: Dirk Schreckmann ]
Joined: Jul 01, 2002
thanx, i think that i understood it. is this name suitable - "andrew"??
Andrew, You need two names separated by a space. For example, "Andrew Smith" or "Anru Depra"
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Joined: Dec 10, 2001
thanx, i think that i understood it. You're welcome and great. is this name suitable - "andrew"?? No. As stated in The JavaRanch Naming Policy, we request that your display name have three parts - a first name or initial, a space, and a last name.