In *LocalServiceImpl#getDateTimeFromRequest, this method should return alternative data instead of throwing an exception when no parameters for date found. Also in the exception, it needs to be printed on the console. The sample code is below.
public Date getDateTimeFromRequest(PortletRequest request, String prefix) {
int Year = ParamUtil.getInteger(request, prefix + "Year");
int Month = ParamUtil.getInteger(request, prefix + "Month") + 1;
int Day = ParamUtil.getInteger(request, prefix + "Day");
int Hour = ParamUtil.getInteger(request, prefix + "Hour");
int Minute = ParamUtil.getInteger(request, prefix + "Minute");
int AmPm = ParamUtil.getInteger(request, prefix + "AmPm");
if (AmPm == Calendar.PM) {
Hour += 12;
}
LocalDateTime ldt;
try {
ldt = LocalDateTime.of(Year, Month, Day, Hour, Minute, 0);
} catch (Throwable e) {
e.printStackTrace();
Date in = new Date();
Instant instant = in.toInstant();
return Date.from(instant);
}
return Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant());
}
In *LocalServiceImpl#getDateTimeFromRequest, this method should return alternative data instead of throwing an exception when no parameters for date found. Also in the exception, it needs to be printed on the console. The sample code is below.