将long值转换为时间

  • Post author:
  • Post category:其他


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 + "毫秒");
	}

}



版权声明:本文为qiujieda原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。