Leniency merely controls whether or not the calendar accepts out-of-range dates. If leniency is set, Java will do some math to adjust out-of-range dates (for example, 2013-12-32 becomes 2014-01-01). If leniency is not set, Java will not allow this, but it doesn't check for out-of-range data until you actually request some of the fields. From the Javadocs:
A non-lenient GregorianCalendar throws an exception upon calculating its time or calendar field values if any out-of-range field value has been set.
To your question then:
How do I handle this?
You can set the calendar to the first of the month:
calendar.set(2013, Calendar.JANUARY, 1);
and then invoke
int days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
and compare against your day value. If your day value is in range, then you can proceed.