getDateStr method
获取日期显示字符串 yyyy-MM-dd EEEE/EE
Implementation
String getDateStr(
{String format = 'yyyy-MM-dd',
MiniLocalType localType = MiniLocalType.zh}) {
String str = format;
if (str.contains('yyyy')) {
String y = _fourDigits(year);
str = str.replaceAll('yyyy', y);
}
if (str.contains('MM')) {
String m = _twoDigits(month);
str = str.replaceAll('MM', m);
}
if (str.contains('dd')) {
String d = _twoDigits(day);
str = str.replaceAll('dd', d);
}
if (str.contains('EEEE')) {
String weekday = getWeekStr(localType);
str = str.replaceAll('EEEE', weekday);
}
if (str.contains('EE')) {
String weekShortStr = getWeekShortStr(localType);
str = str.replaceAll('EE', weekShortStr);
}
return str;
}