1分钟等于多少毫秒
啥也不多说了,直接贴代码,需要的朋友可以拿去直接用,代码比较简单
/*
* 毫秒转化
*/
public static String formatTime(long ms) {
int ss = 1000;
int mi = ss * 60;
int hh = mi * 60;
int dd = hh * 24;
long day = ms / dd;
long hour = (ms - day * dd) / hh;
long minute = (ms - day * dd - hour * hh) / mi;
long second = (ms - day * dd - hour * hh - minute * mi) / ss;
long milliSecond = ms - day * dd - hour * hh - minute * mi - second * ss;
String strDay = day < 10 ? "0" + day : "" + day; //天
String strHour = hour < 10 ? "0" + hour : "" + hour;//小时
String strMinute = minute < 10 ? "0" + minute : "" + minute;//分钟
String strSecond = second < 10 ? "0" + second : "" + second;//秒
String strMilliSecond = milliSecond < 10 ? "0" + milliSecond : "" + milliSecond;//毫秒
strMilliSecond = milliSecond < 100 ? "0" + strMilliSecond : "" + strMilliSecond;
return strMinute + " 分钟 " + strSecond + " 秒";
}
下面是一样的,输出格式不同而已
/*
* 毫秒转化时分秒毫秒
*/
public static String formatTime(Long ms) {
integer ss = 1000;
Integer mi = ss * 60;
Integer hh = mi * 60;
Integer dd = hh * 24;
Long day = ms / dd;
Long hour = (ms - day * dd) / hh;
Long minute = (ms - day * dd - hour * hh) / mi;
Long second = (ms - day * dd - hour * hh - minute * mi) / ss;
Long milliSecond = ms - day * dd - hour * hh - minute * mi - second * ss;
StringBuffer sb = new StringBuffer();
if(day > 0) {
sb.APPend(day+"天");
}
if(hour > 0) {
sb.append(hour+"小时");
}
if(minute > 0) {
sb.append(minute+"分");
}
if(second > 0) {
sb.append(second+"秒");
}
if(milliSecond > 0) {
sb.append(milliSecond+"毫秒");
}
return sb.toString();
}
相关阅读
转载出处:https://blog.csdn.net/ch5256865/article/details/52084484 //将毫秒秒转化为xx小时xx分钟xx秒 function MillisecondTo
将毫秒换算成天、时、分、秒public static String formatDuring(long mss) { long days = mss / (1000 * 60 * 60 * 24);
菜鸟的时候只知道时间戳有10位、13位、还有好长位数的。入坑久了才明白10位数的时间戳是以 秒 为单位;13位数的时间戳是以 毫秒 为
时间戳取10位 long timeStampSec = System.currentTimeMillis()/1000; String timestamp = String.format("%010d