I'm trying to create a Date like this:
date = new Date(year-1900,mon-1,day,hrs,min,sec);
and Eclips gives me this warning: "The constructor Date(int,int,int,int,int) is deprecated".
What does it mean for a constructor to be deprecated? What can I do?
deprecated means the usage of this constructor is discouraged, and it may be removed in future releases of Java. Use the Calendar API.
That means you shouldn't be using it in new code typically because it is dangerous, or because a better alternative exists. Compilers warn when a deprecated program element is used or overridden in non-deprecated code.
In your case, you can use
java.util.Calendar
class instead ofjava.util.Date
.By the way, in Java 8 and later, these old classes are supplanted by the new java.time package (Tutorial). Inspired by Joda-Time, defined by JSR 310, and extended by the ThreeTen Extra project. The old classes remain in place and you may continue to use them (while avoiding their deprecated parts), but you are encouraged to transition to the new classes.
As it is deprecated means that you ought not really use it. You could use Calendar to generate a date from fields instead.