Link to home
Start Free TrialLog in
Avatar of fyness
fyness

asked on

Java Calendar class - exception when using setTime()


Hi,
Can anyone see anything wrong with this while loop?

while (dateResultSet.next()) {                           
               Date directDebitDate = dateResultSet.getDate("direct_debit_date");                           
                         Calendar allowable = Calendar.getInstance();
                    Calendar directDebitDueDate = Calendar.getInstance();
                      
            /* set calendar value to 3 days time */                                                
                           allowable.add(Calendar.DATE, 3);                                                
                           directDebitDueDate.setTime(directDebitDate);
                           
                           /* if it falls before 3 days time it is classified as urgent */
                           if (directDebitDueDate.before(allowable))
                           {
                                 urgentPending ++;    
                                 System.out.println("Urgent pending count " + urgentPending);
                           }else
                           {
                                 regularPending ++;
                                 System.out.println("Regular pending count " + regularPending);
                           }                            
                           
                     }


 When i run it the results from of the system.outs come up fine but the setTime method causes the following exception

Caused by: java.lang.NullPointerException
      at java.util.Calendar.setTime(Calendar.java:902)
      ... 34 more
Caused by:
java.lang.NullPointerException
      at java.util.Calendar.setTime(Calendar.java:902)
      at ie.sentenial.business.database.MySQLDataManager.getClientCustomerStatuses(Unknown Source)
      at ie.sentenial.business.database.MySQLDataManager.getClientCustomerStatuses(Unknown Source)
      at ie.sentenial.application.actions.LoginAction.getClientCustomerStatusDetails(Unknown Source)
      at ie.sentenial.application.actions.LoginAction.execute(Unknown Source)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)

Any ideas anyone???
ASKER CERTIFIED SOLUTION
Avatar of KeithWatson
KeithWatson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial