Adding null check in date format code.