// check that it is valid format
// d,m,y
// m,y
// y
if ((nYearFrom != null && nMonthFrom != null && nDayFrom != null ||
nYearFrom != null && nMonthFrom != null ||
nYearFrom != null) &&
(nYearTo != null && nMonthTo != null && nDayTo != null ||
nYearTo != null && nMonthTo != null ||
nYearTo != null))
After a short thinking, this condition can be simplified to:
if (nYearFrom != null && nYearTo != null)
Hm. But if nYearFrom is unequal null and nYearTo is unequal null too then something like nMounthFrom.equals("00") would still lead to an NullPointerException what the first version prevents.
ОтветитьУдалить