Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. Calendar c = Calendar.getInstance();
  2. c.set(Calendar.MONTH, month); // 0-based
  3. c.set(Calendar.YEAR, year);
  4.  
  5. Calendar cal = Calendar.getInstance();
  6. cal.set(Calendar.YEAR, year);
  7. cal.set(Calendar.MONTH, month);
  8.  
  9. Calendar calendar = Calendar.getInstance();
  10. calendar.set(Calendar.MONTH, Calendar.MAY); // note this is a 0-11 value for jan-dec
  11. calendar.set(Calendar.DATE, 20); // pick the 20th day...or whatever from input
  12.  
  13. YearMonth ym = YearMonth.of( 2017 , Month.MARCH );
  14.  
  15. LocalDate firstOfMonth = ym.atDay( 1 );
  16. LocalDate endOfMonth = ym.atEndOfMonth();
  17.  
  18. List<LocalDate> dates = new ArrayList<>( 31 );
  19. LocalDate localDate = ym.atDay( 1 );
  20. while ( YearMonth.from( localDate ).equals( ym ) {
  21. dates.add( localDate );
  22. // Set up the next loop.
  23. localDate = localDate.plusDays( 1 );
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement