Hello I am trying to get the current date at java at a Class I created but everything fails. I\'ve seen in many sites e.g. http://www.mkyong.com/java/java-date-and-calenda
The examples you found are for java.util.Date while you are using java.sql.Date
java.sql.Date
has two constructors
Date(long date)
: Constructs a Date object using the given milliseconds time value.Date(int year, int month, int day)
: which is deprecatedand no default Date()
constructor.
java.util.Date
among others has a default constructor without arguments
Date()
: Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.When importing classes, Eclipse will help you fining possible candidates but always check if the first suggestion is really what you want.