C implements a method for converting milliseconds to minutes

  • 2021-01-03 21:01:49
  • OfStack

This article is an example of how C# implements the conversion of milliseconds to minutes. Share to everybody for everybody reference. Specific implementation methods are as follows:


public static String formatLongToTimeStr(Long l) {
    String str = "";
    int hour = 0;
    int minute = 0;
    int second = 0;
    second = l.intValue() / 1000;
 
    if (second > 60) {
      minute = second / 60;
      second = second % 60;
    }
    if (minute > 60) {
      hour = minute / 60;
      minute = minute % 60;
    }
    return (hour.toString() + " hours " + minute.toString() + " minutes "
        + second.toString() + " seconds ");
}

Hopefully this article has helped you with your C# programming.


Related articles: