formatDate method
Formats the date into a string using the given targetFormat.
Attempts to format using multiple fallback locales.
Example:
myDate.formatDate(targetFormat: "dd MMM yyyy");
Returns empty string if null or formatting fails.
Implementation
String formatDate({String? targetFormat = 'dd MM yyyy'}) {
if (this == null) return '';
for (final locale in _supportedLocales) {
try {
return DateFormat(targetFormat, locale).format(this!);
} catch (_) {}
}
return "";
}