欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

返回月份最大天数

程序员文章站 2022-03-15 15:03:50
...
<%  String year = session.getAttribute("year").toString();
String month =session.getAttribute("month").toString();
String day = "01";
String t = year+"-"+month+"-"+day;
Calendar calendar = Calendar.getInstance();
int months = Integer.parseInt(month);
int years = Integer.parseInt(year);
int days =1;
calendar.set(years,months-1,days);
int dayst =calendar.getActualMaximum(calendar.DAY_OF_MONTH);
System.out.println("-months--"+months+"days--"+dayst);
String dd= (new Integer(dayst)).toString();
String lastDay = year+"-"+month+"-"+dd;
System.out.println("-lastDay--"+lastDay);
%>
相关标签: JSP