利用Calendar获取本月第一天和上月最后一天

public static void main(String[] args) {
		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.DAY_OF_MONTH,0);
		Date time = calendar.getTime();
		System.out.println("上个月最后一天:"+time);

		Calendar calendar1 = Calendar.getInstance();
		calendar1.set(Calendar.DAY_OF_MONTH,1);
		Date time1 = calendar1.getTime();
		System.out.println("本月第一天:"+time1);
	}

 

你可能感兴趣的:(后端开发)