Formatting a Duration like HH:mm:ss

后端 未结 11 961
孤城傲影
孤城傲影 2020-12-05 22:53

Is there a good way to format a Duration in something like hh:mm:ss, without having to deal with time zones?

I tried this:

DateTime durationDate = Da         


        
11条回答
  •  醉梦人生
    2020-12-05 23:39

    You can use this:

    print('${duration.inHours.toString().padLeft(2, '0')}:
    ${duration.inMinutes.remainder(60).toString().padLeft(2, '0')}:
    ${duration.inSeconds.remainder(60).toString().padLeft(2, '0')}');
    

提交回复
热议问题