formatF method
日期 format 转换格式,自定义转换格式
Implementation
String formatF(String format) {
var dateTime = this;
if (dateTime == null) return '';
if (format.contains('yy')) {
String year = dateTime.year.toString();
if (format.contains('yyyy')) {
format = format.replaceAll('yyyy', year);
} else {
format = format.replaceAll(
'yy', year.substring(year.length - 2, year.length));
}
}
format = _comformat(dateTime.month, format, 'M', 'MM');
format = _comformat(dateTime.day, format, 'd', 'dd');
format = _comformat(dateTime.hour, format, 'H', 'HH');
format = _comformat(dateTime.minute, format, 'm', 'mm');
format = _comformat(dateTime.second, format, 's', 'ss');
format = _comformat(dateTime.millisecond, format, 'S', 'SSS');
return format;
}