标签:add [] imp cal lis time() string instance format
private String[] getDateArrByMonth(Date startDate, Date endDate) {
Calendar c = Calendar.getInstance();
List<String> list = new ArrayList<String>();
SimpleDateFormat df = new SimpleDateFormat("yyyy年MM月");
for (; startDate.getTime() <= endDate.getTime();) {
String _startDate = df.format(startDate);
list.add(_startDate);
c.setTime(startDate);
c.add(Calendar.MONTH, 1); //加一个月
startDate = c.getTime();
}
String[] ret = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
ret[i] = list.get(i);
}
return ret; }
标签:add [] imp cal lis time() string instance format
原文地址:http://www.cnblogs.com/cuijinlong/p/6230264.html