【发布时间】:2012-02-04 17:09:44
【问题描述】:
//get current date
SimpleDateFormat monthFormat = new SimpleDateFormat("M");
int _currentMonth = Integer.parseInt(monthFormat.format(new Date(System.currentTimeMillis())));
SimpleDateFormat yearFormat = new SimpleDateFormat("YYYY");
int _currentYear = Integer.parseInt(yearFormat.format(new Date(System.currentTimeMillis())));
我正在尝试构建一个日历视图,并从检索当前年份和月份开始。但是,返回的是一个字符串,而我想要一个 int 在数组等中使用。
上面发布的代码给了我一个错误,很可能是由于 Integer.parseInt 函数。
我不能用吗?检索年、月和日的最佳方法是什么。
【问题讨论】:
标签: java blackberry