What is the accepted way to replace java.util.Date(year,month,day)

The idea is to use the Calendar class, like so:

Calendar cal = Calendar.getInstance();
cal.set(year, month, date);
Date date = cal.getTime();

Indeed, if you check the Javadoc of the constructor you are mentioning, it is exactly what is suggested:

Date(int year, int month, int date)
          Deprecated. As of JDK version 1.1, replaced by Calendar.set(year + 1900, month, date) or GregorianCalendar(year + 1900, month, date).

Or … use JodaTime :-).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)