Fix dates issue.

When date is not required it will be null and if you try to initialize new Date(date) it will trow NullPointerException.