蔡香满屋
站在牛顿头上吃苹果
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		for (MyUpcomingVo myUpcomingVo : myUpcomingVoList) {
			long nd = 1000 * 24 * 60 * 60;
			long nh = 1000 * 60 * 60;
			long nm = 1000 * 60;
			Date nowDate;
			try {
				nowDate = df.parse(df.format(new Date()));
				System.out.println(nowDate.getTime() - df.parse(myUpcomingVo.getProcessNodeExamineTime()).getTime());
				// 获得两个时间的毫秒时间差异
				long diff = (nowDate.getTime() - df.parse(myUpcomingVo.getProcessNodeExamineTime()).getTime());
				// 计算差多少天
				long day = diff / nd;
				// 计算差多少小时
				long hour = diff % nd / nh;
				// 计算差多少分钟
				long min = diff % nd % nh / nm;
				myUpcomingVo.setDeadline("已耗时" + day + "天" + hour + "小时" + min + "分钟");
			} catch (Exception e) {
				throw new RuntimeException(e.getMessage());
			}

 取得的结果效果图如:

 

posted on 2019-04-19 09:08  蔡香满屋  阅读(1723)  评论(0)    收藏  举报