Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class java.util.Date ......

 
Andrew Lit
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this class has been deprecated here:
int day = d.getDay();
and i can't understand why. Could someone explain me pls.
i use jdk 1.3.1
i would be appreciated for the help. Sorry for my english.
 
Stu Glassman
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Andrew Lit
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for the help, it workdes. But i still can't understand why i couldn't do it that way
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anru,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Andrew Lit
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx, i think that i understood it.
is this name suitable - "andrew"??
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew,
You need two names separated by a space. For example, "Andrew Smith" or "Anru Depra"
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic