DateTime? toDateTime(String pattern) { try { return DateFormat(pattern).parse(this); } on Exception catch (e) { print(e); return null; } }