secToTime static method

String secToTime(
  1. int mseconds
)

int 转 显示时间

Implementation

static String secToTime(int mseconds) {
  if (mseconds == 0) return '00 : 00 : 00';

  int seconds = mseconds ~/ 1000;
  int hour = seconds ~/ 3600;
  int minute = (seconds - hour * 3600) ~/ 60;
  int second = (seconds - hour * 3600 - minute * 60);

  final showHour = hour < 10 ? '0$hour' : hour;
  final showMinute = minute < 10 ? '0$minute' : minute;
  final showSecond = second < 10 ? '0$second' : second;
  return '$showHour : $showMinute : $showSecond';
}