 			}
 		} else if textField == expirationDateTextField {
 			let date: Date?
-			if let expDateString = expirationDateTextField.text {
+			if let expDateString = expirationDateTextField.text,
+				expDateString != "" {
 				date = dateFormatter!.date(from: expDateString)
 			} else {
 				date = nil

		dateFormatter!.dateStyle = .short
		dateFormatter!.timeStyle = .none
		
		brandTextField.text = product!.brand
		nameTextField.text = product!.name
		setPriceText(with: product!.price)

		super.viewWillDisappear(animated)
		
		notificationToken?.stop()
	}
}

extension ProductViewController {
	func expirationDateChanged(_ sender: UIDatePicker) {
		let datePicker = expirationDateTextField.inputView! as! UIDatePicker
		let expirationDate = datePicker.date
		setExpirationDateText(with: expirationDate)
	}
}

