将毫秒时间长度转化为时分秒

public static String formatDuring(long mss) {
  long days = mss / (1000 * 60 * 60 * 24);
  long left=mss%(1000 * 60 * 60 * 24);
  long hours = left / (1000 * 60 * 60);
  left=left % (1000 * 60 * 60);
  long minutes = left/ (1000 * 60);
  left=left%(1000 * 60);
  long seconds = left / 1000;
  left=left%1000;
  String s= days>0?(days+"Days "):("");
  s+=hours>0?(hours+"Hours "):("");
  s+=minutes>0?(minutes+"Minutes "):("");
  s+=seconds>0?(seconds+"Seconds "):("");
  s+=left>0?(left+"ms"):("");
  return s;
 }

一种很自然的计算方法。

你可能感兴趣的:(return,public,seconds,Minutes)