1、获取据现在n月前或n月后的年份、月初、月末
public static int getMonth(int offset) {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) + offset);
return cal.get(Calendar.MONTH) + 1;//获取月份
}
return cal.get(Calendar.YEAR);//获取年份
return cal.getActualMaximum(Calendar.DAY_OF_MONTH);//获取月末
2、sqlite数据库里根据日期查询
SELECT * ID from yd_FeeDetailed where datetime(SysTime) between datetime(‘2017-04-01 00:00:00’) and datetime(‘2017-04-30 23:59:59’);