How to solve disabled MaxDate problem in ADF Calendar component?

How to solve disabled MaxDate problem in ADF Calendar component?

In my previous post I had explained how to disabled future date using MaxValue property of date component. But there was an issue, which disables Max date too.

It’s because, the date object returns date as dd/mm/yyyy 00:00 (notice the time value which is 00:00). At the time of selection, the date including current time (could be dd/mm/yyyy 00:01 +) exceeds the value returned by date object and thus the max date is disabled in the component.

To avoid this, it is advised to create the Date object with maximum value for any date-time components that aren’t displayed (usually hours, minutes, seconds, milliseconds) to allow the largest range of values to be accepted.

As you can seen in following code I have added max time in date object (23,59,59 hh:mi:ss)

public Date getCurrentDate() {
Date cdate = null;
try {
Calendar cal = Calendar.getInstance();
GregorianCalendar gc =
new GregorianCalendar(cal.get(Calendar.YEAR),
cal.get(Calendar.DATE) + 0, 23, 59, 59);

cdate = new Date(gc.getTimeInMillis());

} catch (Exception e) {
return cdate;


About Manish Pandey

Manish is a Project Leader at Jagran Prakashan Ltd, focused on Jdeveloper Fusion Web Application(specifically Oracle ADF). He shares his knowledge through the OTN Jdev/ADF Forum. He has written more than 50 article about Oracle ADF and Jdeveloper.

Leave a Reply