문제

I am using jDateChooser plugin on netbeans. When application starts it throws nullpointerException but when I choose date it works fine. The one and only one problem is it throws exception at runtime. Following is my code where I am getting exception:

String startDate=new SimpleDateFormat("yyyy-MM-dd").format(filterByStartDateChooser.getDate())

Note: I am using netbeans gui to design form.

Please solve my issue.Thanks

도움이 되었습니까?

해결책

This might happen during initialisation. some function or actionlistener might want to read out the jdatechooser while it has no date set. to avoid this, simply add

jDateChooser.setCalendar(Calendar.getInstance());

after creatign your jDatechooser.

다른 팁

   String startDate = null;
  if(filterByStartDateChooser.getDate()!=null )
         startDate = new SimpleDateFormat("yyyy-MM-dd").format(dateFromDateChooser.getDate());
  if(startDate !=null){
            --------------
            ---------------
  }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top