Refactor and Fixed bug for parsing dates->getDate method