欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

将秒转换为天时分秒格式数组返回 java时间日期时分秒 

程序员文章站 2022-05-09 19:25:02
...
	private static final int FORMAT_DAY = 0;
	private static final int FORMAT_HOUR = 1;
	private static final int FORMAT_MINUTE = 2;
	private static final int FORMAT_SECOND = 3;
	/**
	 * 将秒转换为天时分秒格式数组
	 * @param seconds 秒数
	 * @return 返回天时分秒数组
	 */
	private static long[] splitMilliSeconds(final long millisecond) {
		long unitDay = 86400;
		long unitHour  = 3600;
		long unitMinute = 60;
		long day,hour,minute,second = 0L;
		long seconds = millisecond /1000;
		day = seconds / unitDay;
		hour = seconds % unitDay / unitHour ;
		minute = seconds % unitDay % unitHour / unitMinute;
		second = seconds % unitDay % unitHour % unitMinute;
		long[] tArray = {day,hour,minute,second};
		return tArray;
	}