title: Getting date from mongodb java to jsp shows null
body: <p>The setter and getters are Date type
  This is my code for the connection:</p>
  
  <pre><code>    public void connectToDb() {
          try {
              MongoClient mongoClient = new MongoClient("localhost", 27017);
              DB db = mongoClient.getDB("bookingSystem");
              bookingsCol = db.getCollection("bookings");
          } catch (Exception e) {
              System.err.println(e.getClass().getName() + ": " + e.getMessage());
           }
        }
  </code></pre>
  
  <p>The code for getting the values in mongo which is:</p>
  
  <hr>
  
  <pre><code>    "_id" : ObjectId("5820145df23fc5ccffd52155"),
      "userID" : "1B",
      "bookings" : [
                      {
                      "startDateTime" : ISODate("2017-08-22T08:00:00Z")
                      }
                    ]
  </code></pre>
  
  <hr>
  
  <pre><code>    public Booking getBooking(int bookingID, String userID) {
          connectToDb();
          BasicDBObject query = new BasicDBObject();
          query.put("bookings.bookingID", bookingID);
          DBCursor cursor = bookingsCol.find(query);
          while (cursor.hasNext()) {
          DBObject theObj = cursor.next();
  
          BasicDBList bookingsList = (BasicDBList) theObj.get("bookings");
          for (int i = 0; i &lt; bookingsList.size(); i++) {
              BasicDBObject bookingObj = (BasicDBObject) bookingsList.get(i);
              Date startDateTime = bookingObj.getDate("startDateTime");
              booking.setStartDateTime(startDateTime);
          }
      }
      return booking;
     }
  </code></pre>
  
  <p>when i return the value, receiving the format : Fri Sep 22 12:00:00 MUT 2017 which is good, as it matches my input but when i do booking.getStartDateTime() from jsp. for date it is null, but the size is 1. The </p>
  
  <p>In the jsp now the the getListOfBooking() is a function in my booking class which returns an Array of Objects that is why i did the .size() to know if it has values. I tried doing it with a string and it works however with the date it shows error.</p>
  
  <pre><code>        &lt;%
          out.println(bookings.getListOfBooking().get(0).getStartDateTime());
          out.println(bookings.getListOfBooking().size());
          %&gt;
  </code></pre>