java 得到某个月的第一天和最后一天

private static SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyyMMdd");
	public static void main(String[] args) throws ParseException {
		// TODO Auto-generated method stub
		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
		Date date = calendar.getTime();
		String firstDate = dateFormat2.format(date);
		System.err.println(firstDate);
		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
		date = calendar.getTime();
		String lastDate = dateFormat2.format(date);
		System.err.println(lastDate);
	}

你可能感兴趣的:(java)