android Fatal Exception: java.lang.NullPointerException when opening the DatePickerDialog

Issue was the minDate was higher than the maxDate in some random cases because of some server issues.I was not handling the scenario thinking the minDate(What i was getting) will always be lesser than the System.currentTimeMillis(). So need to handle the scenario :

            if(System.currentTimeMillis() > minCal.getTimeInMillis()){
                dialog.getDatePicker().setMinDate(minCal.getTimeInMillis());
                dialog.getDatePicker().setMaxDate(System.currentTimeMillis());
                dialog.getDatePicker().setCalendarViewShown(false);
                dialog.show();
            }else{

                //Error message depending on the requirements.

            }