stringToDate static method
Implementation
static DateTime? stringToDate(String dateString, {String? dateFormat}){
DateTime? dateTime;
try {
dateTime = DateTime.parse(dateString).toLocal();
}catch(e){
logNUI("NUIDTUtil", "Failed to parse date directly with error : $e");
}
if(dateTime == null){
try{
if(!isNullOrEmpty(dateFormat)){
dateTime = DateFormat(dateFormat).parse(dateString).toLocal();
}
else{
dateTime = DateFormat(detectDateFormat(dateString)).parse(dateString).toLocal();
}
}catch(e){
logNUI("NUIDTUtil", "Failed to parse date dynamicly with error : $e");
}
}
return dateTime;
}