得到一周开始时间和结束时间

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		// 得到当前日期
		Calendar cal = Calendar.getInstance();
		Date toDay = cal.getTime();

		// 得到本周第一天日期
		int day_of_week = cal.get(Calendar.DAY_OF_WEEK) - 2;
		cal.add(Calendar.DATE, -day_of_week);
		Date weekFirst = cal.getTime();
		String weekFirststr = formatter.format(weekFirst);

		// 得到本周最后一天
		cal.add(Calendar.DATE, 6);
		Date weekLast = cal.getTime();
		String weekLaststr = formatter.format(weekLast);
 

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