DateUtil class

Utility class for date and time formatting and manipulation.

Provides pre-configured date formatters and helper methods for common date/time operations and conversions.

Constructors

DateUtil()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

ddmmm → DateFormat
Date format: dd-MMM (e.g., "15-Jan").
final
ddmmmyyyy → DateFormat
Date format: dd-MMM-y (e.g., "15-Jan-2024").
final
ddmmyhhmma → DateFormat
Date and time format: dd-MMM-y h:mm a (e.g., "15-Jan-2024 2:30 PM").
final
ddmmyhhmmssaaa → DateFormat
Date and time format: dd-MMM-y HH:mm:ss (e.g., "15-Jan-2024 14:30:45").
final
ddmmyyyy → DateFormat
Date format: dd-MMM-y (e.g., "15-Jan-2024").
final
eee → DateFormat
Day of week format: EEE (e.g., "Mon").
final
eeehhmma → DateFormat
Day and time format: EEE hh:mm a (e.g., "Mon 02:30 PM").
final
hh12mma → DateFormat
12-hour time format with AM/PM (hh:mm a).
final
hh24mmss → DateFormat
24-hour time format (HH:mm:ss).
final
yyyymm → DateFormat
Date format: y-MM (e.g., "2024-01").
final
yyyymmdd → DateFormat
Date format: yMMdd (e.g., "20240115").
final
yyyymmddhhmmssForFileName → DateFormat
Date and time format suitable for file names: y-MM-dd-HH-mm-ss.
final
yyyymmm → DateFormat
Date format: y-MMM (e.g., "2024-Jan").
final

Static Methods

addDaysAndSetHHMM(DateTime ref, int days, String hhColonMM) DateTime
Adds days to a reference date and sets the time to the specified HH:MM.
formatDateDDMMMYHHMMSS(int millis) String
Formats milliseconds since epoch to "dd-MMM-y HH:mm:ss" format.
formatDateFriendlyDateAndTimeUptoMillis(int millis) String
Formats milliseconds since epoch to friendly date-time with milliseconds.
formatDateHHMMSS(int millis) String
Formats milliseconds since epoch to HH:mm:ss format.
formatTimeOfDay(TimeOfDay? timeOfDay, {bool formatTo12Hr = true}) String
Formats a TimeOfDay to a string.
getElapsedStr(Duration duration, {bool showMilliSeconds = false}) String
Converts a Duration to a human-readable elapsed time string.
parseHHColonMMToTimeOfDay(String? hhColonMM) TimeOfDay
Parses a nullable HH:MM string to TimeOfDay.
parseHHMMToTimeOfDay(String hhmm) TimeOfDay
Parses a HH:MM string to a TimeOfDay.
reduceDaysAndSetHHMM(DateTime ref, int days, String hhColonMM) DateTime
Subtracts days from a reference date and sets the time to the specified HH:MM.