toDateFromUTC static method
String
toDateFromUTC(
- int year,
- int month,
- int day, [
- TimeFormats timeFormat = TimeFormats.none,
- DateFormats dateFormat = DateFormats.none,
- String? pattern,
- String separator = "",
- String? local,
Converts UTC components to a formatted date string.
Example:
String utcDate = DateProvider.toDateFromUTC(2024, 2, 6);
print(utcDate); // Output: "06-02-2024"
Implementation
static String toDateFromUTC(
int year,
int month,
int day, [
TimeFormats timeFormat = TimeFormats.none,
DateFormats dateFormat = DateFormats.none,
String? pattern,
String separator = "",
String? local,
]) {
if ((year + month + day) > 0) {
return DateTime.utc(year, month, day).toDate(
timeFormat: timeFormat,
dateFormat: dateFormat,
format: pattern,
separator: separator,
local: local,
);
} else {
return '';
}
}