pGetDateTimeCustomFormat static method

String pGetDateTimeCustomFormat(
  1. DateTime? dateTime,
  2. String format, {
  3. String? defaultValue,
  4. String? localization,
})

Formats dateTime with a custom format.

Implementation

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