getTime static method
DateTime或者时间戳转字符串
Implementation
static String? getTime({
DateTime? dateTime,
int? milliseconds,
DateFormat format = DateFormat.NORMAL,
String? dateSeparate,
String? timeSeparate,
bool? isZh = false,
}) {
String? result;
if (dateTime == null && milliseconds == null) {
String dateStr = DateTime.now().toString();
result = formatDateTime(dateStr, format, dateSeparate, timeSeparate, isZh);
}
if (dateTime != null) {
String dateStr = dateTime.toString();
result = formatDateTime(dateStr, format, dateSeparate, timeSeparate, isZh);
return result;
}
if (milliseconds != null) {
if (milliseconds == 0) {
result = "";
}
DateTime dateTime = getDateTime(milliseconds: milliseconds);
result = getTime(
dateTime: dateTime,
format: format,
dateSeparate: dateSeparate,
timeSeparate: timeSeparate,
);
}
return result;
}