GregorianCalendar constructor have signature:
GregorianCalendar(int year, int month, int dayOfMonth)
GregorianCalendar(int year, int month, int dayOfMonth, int hourOfDay, int minute, int second)
What happen if I pass month
or dayOfMonth
out of constructor contract?
It is easy to check if month in 0-11 range. But it is impossible to check valid day (which should be 28/29/30/31?) without writing own Calendar implementation.
It should be nice if Java Platform checks user date input. I don't like to check if 2015-13-32
is valid ISO date in own code.