toDate method
String
toDate({
- String? format,
- String? local,
- TimeFormats? timeFormat,
- DateFormats dateFormat = DateFormats.dateDMCY,
- String? separator,
Converts the custom date to a formatted string.
The method provides flexibility for custom formatting options.
Parameters:
format
: Custom date and time format string.local
: Optional parameter to specify the locale for formatting.timeFormat
: Enum specifying the time format (e.g., hour, minute, second).dateFormat
: Enum specifying the date format (e.g., day, month, year).separator
: Separator string between date and time components.
Example:
int myDate = DateTime.now().millisecondsSinceEpoch;
String formattedDate = myDate.toDate(
dateFormat: DateFormats.dateDMCY,
timeFormat: TimeFormats.timeHMa,
separator: " at ",
);
print(formattedDate); // Output: "06-02-2024 at 03:45 PM"
Implementation
String toDate({
String? format,
String? local,
TimeFormats? timeFormat,
DateFormats dateFormat = DateFormats.dateDMCY,
String? separator,
}) {
return DateTime.fromMillisecondsSinceEpoch(_v).toDate(
timeFormat: timeFormat,
dateFormat: dateFormat,
format: format,
separator: separator,
local: local,
);
}