public class ParseLongToTime {
public static void main(String[] args) {
long timeTemp = System.currentTimeMillis();
long time = timeTemp;
long mSec = time % 1000;
time /= 1000;
long year = time / (365 * 24 * 3600);
time = time % (365 * 24 * 3600);
long month = time / (30 * 24 * 3600);
time = time % (30 * 24 * 3600);
long day = time / (24 * 3600);
time = time % (24 * 3600);
long hour = time / 3600;
time = time % 3600;
long min = time / 60;
time = time % 60;
long sec = time;
System.out.println("long值【"+timeTemp + "】转换时间是:" + year + "年" + month + "月" + day
+ "天" + hour + "小时" + min + "分钟" + sec + "秒零" + mSec + "毫秒");
}
}
将long值转换为时间
最新推荐文章于 2023-03-09 15:00:00 发布