Calender函数

 //获取明天日期,并且设定为十点 Calendar calendar = GregorianCalendar.getInstance(); calendar.add(Calendar.DAY_OF_YEAR, 1); calendar.set(Calendar.HOUR_OF_DAY, 10); calendar.set(Calendar.MINUTE, 00); DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm"); System.out.println(df.format(calendar.getTime()));

 //根据给定的年份,和月份查询当前年月的最大天数 Calendar calendar = GregorianCalendar.getInstance(); calendar.set(Calendar.YEAR, 2008); calendar.set(Calendar.MONTH, 1); //月份是从(0-11),所以显示的是二月的天数 DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); System.out.println(df.format(calendar.getTime())); System.out.println(calendar.getActualMaximum(Calendar.DAY_OF_MONTH));

 

你可能感兴趣的:(Calender函数)