I have the following code and want to set cal to 01.01.2016
.
DateFormat dateFormat = new SimpleDateFormat("dd.MM.YYYY");
Calendar cal = Calendar.getInstance();
cal.set(2016, Calendar.JANUARY, 1);
System.out.println(dateFormat.format(cal.getTime()));
But it always return 01.01.2015
. I tried to set year to 2017
, it outputs 2016
. For 2015
, 2014
and 2018
, it works correctly.