获取今天距离指定时间还有几天几时几分几秒

	/**
	 * 获取今天还剩下多少秒
	 * @return
	 */
	public static int getMiao(){
		Calendar curDate = Calendar.getInstance();
		Calendar tommorowDate = new GregorianCalendar(curDate
				.get(Calendar.YEAR), curDate.get(Calendar.MONTH), curDate
				.get(Calendar.DATE) + 1, 0, 0, 0);
		return (int)(tommorowDate.getTimeInMillis() - curDate.getTimeInMillis()) / 1000;
	}
	
	/**
	 * 获取今天距离指定时间还有多久
	 * @return
	 */
	public static String getSjc(Date date){
		Calendar curDate = Calendar.getInstance();
		Calendar tommorowDate = Calendar.getInstance();
		tommorowDate.setTime(date);
		long miao = (tommorowDate.getTimeInMillis() - curDate.getTimeInMillis())/1000;
		int day = (int)(miao / (60*60*24));				//天
		int hour = (int)(miao % (60*60*24) / (60*60));	//时
		int mm = (int)(miao % (60*60) / 60);			//分
		int sec = (int)(miao % 60);						//秒
		return day+"天"+hour+"时"+mm+"分"+sec+"秒";
	}

你可能感兴趣的:(时间)