Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Calendar c = Calendar.getInstance();
- c.set(Calendar.MONTH, month); // 0-based
- c.set(Calendar.YEAR, year);
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.YEAR, year);
- cal.set(Calendar.MONTH, month);
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.MONTH, Calendar.MAY); // note this is a 0-11 value for jan-dec
- calendar.set(Calendar.DATE, 20); // pick the 20th day...or whatever from input
- YearMonth ym = YearMonth.of( 2017 , Month.MARCH );
- LocalDate firstOfMonth = ym.atDay( 1 );
- LocalDate endOfMonth = ym.atEndOfMonth();
- List<LocalDate> dates = new ArrayList<>( 31 );
- LocalDate localDate = ym.atDay( 1 );
- while ( YearMonth.from( localDate ).equals( ym ) {
- dates.add( localDate );
- // Set up the next loop.
- localDate = localDate.plusDays( 1 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement