pDateToString static method

String pDateToString(
  1. DateTime? dateTime, {
  2. String? defaultValue,
  3. String? localization,
})

Converts a DateTime object to a formatted date string.

Implementation

static String pDateToString(DateTime? dateTime,
    {String? defaultValue, String? localization}) {
  if (dateTime == null) return defaultValue ?? '';
  try {
    return pDateFormatter(localization: localization).format(dateTime);
  } catch (e) {
    if (kDebugMode) print('pDateToString error: $e');
    return defaultValue ?? '00-00-0000';
  }
}