formatDateTime function

  1. @Deprecated('Use .toDisplayDate extension instead.')
String formatDateTime(
  1. String dateTime, {
  2. String? newDateTimeFormat,
})

formatDateTime method this method will format a date string in default or format provided.

Implementation

@Deprecated('Use .toDisplayDate extension instead.')
String formatDateTime(String dateTime, {String? newDateTimeFormat}) {
  dateTime = dateTime.replaceNullWithEmpty;

  if (dateTime.toString().isNotEmpty) {
    /// formatting date in yyyy-MM-dd HH:mm:ss format
    dateTime = DateFormat(newDateTimeFormat ?? kDefaultDateTimeFormat).format(DateTime.parse(dateTime));
  }

  return dateTime;
}