1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Calendar cale = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); String firstday, lastday;
cale = Calendar.getInstance(); cale.add(Calendar.MONTH, 0); cale.set(Calendar.DAY_OF_MONTH, 1); firstday = format.format(cale.getTime());
cale = Calendar.getInstance(); cale.add(Calendar.MONTH, 1); cale.set(Calendar.DAY_OF_MONTH, 0); lastday = format.format(cale.getTime());
String nextFirstday, nextLastday; Calendar nextCale = Calendar.getInstance();
nextCale.set(Calendar.MONTH, nextCale.get(Calendar.MONTH) + 1); nextCale.set(Calendar.DAY_OF_MONTH, 1); nextFirstday = format.format(nextCale.getTime());
nextCale.set(Calendar.MONTH, nextCale.get(Calendar.MONTH) + 1); nextCale.set(Calendar.DAY_OF_MONTH, 0); nextLastday = format.format(nextCale.getTime());
|