计算二个时间间隔天数,保留一位小数

public static String getQuot(Date startDate, Date endDate) {
		String retQuot = "";
		try {
			long timeout = endDate.getTime() - startDate.getTime();
			double quot = 0.0;
			quot = ((double)timeout) / 1000 / 60 / 60 / 24;
			
			DecimalFormat formater = new DecimalFormat();
	        formater.setMaximumFractionDigits(1);
	        formater.setGroupingSize(0);
	        formater.setRoundingMode(RoundingMode.FLOOR);
	        retQuot = formater.format(quot);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return retQuot;
	}

发布了87 篇原创文章 · 获赞 22 · 访问量 19万+

猜你喜欢

转载自blog.csdn.net/gaofenglxx/article/details/60139965