我正在尝试用Java编写一个Calendar
,该Java输出一个在表内带有html
的Calendar
网页,但是在尝试获取特定月份的天数时遇到了问题在特定年份。
这是我正在使用的代码:
//accept input from command prompt in form of MONTH, DAY, YEAR
String date = args[0];
SimpleDateFormat df = new SimpleDateFormat("MMMM dd, yyyy");
Date convertedDate = new Date();
try
{
convertedDate = df.parse(date);
}
catch(Exception e)
{
System.out.print(e);
}
Calendar cal = Calendar.getInstance();
cal.setTime(convertedDate);
year = cal.get(Calendar.YEAR);
month = cal.get(Calendar.MONTH);
day = cal.get(Calendar.DAY_OF_MONTH);
//get number of days in month
int numDays, startMonth;
numDays = cal.getActualMaximum(DAY_OF_MONTH);
我从最后一行读取错误:
error: cannot find symbol and it points to the DAY_OF_MONTH variable.
我该如何解决?
最佳答案
关于java - 尝试使用Calendar对象获取特定月份的天数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12327122/