formatDateTime static method
Format datetime string
Implementation
static String formatDateTime(int value, String format) {
if (format.isEmpty) {
return value.toString();
}
String result = format;
// format year text
if (format.contains('y')) {
result = _formatYear(value, result);
}
// format month text
if (format.contains('M')) {
result = _formatMonth(value, result);
}
// format day text
if (format.contains('d')) {
result = _formatDay(value, result);
}
if (format.contains('E')) {
result = _formatWeek(value, result);
}
// format hour text
if (format.contains('H')) {
result = _formatHour(value, result);
}
// format minute text
if (format.contains('m')) {
result = _formatMinute(value, result);
}
// format second text
if (format.contains('s')) {
result = _formatSecond(value, result);
}
if (result == format) {
return value.toString();
}
return result;
}