fork(1) download
  1. import java.time.LocalDate;
  2. import java.time.Month;
  3. import java.time.YearMonth;
  4. import java.util.List;
  5. import java.util.stream.Collectors;
  6. import java.util.stream.IntStream;
  7.  
  8. public class Main {
  9. public static void main(String[] args) {
  10. // Test
  11. getDateList(2017, "February").forEach(System.out::println);
  12. System.out.println("=*==*==*=*=");
  13. getDateList(2016, "February").forEach(System.out::println);
  14. }
  15.  
  16. static List<LocalDate> getDateList(int year, String monthname) {
  17. int month = Month.valueOf(monthname.toUpperCase()).getValue();
  18.  
  19. return IntStream
  20. .rangeClosed(1, YearMonth.of(year, month).lengthOfMonth())
  21. .mapToObj(i -> LocalDate.of(year, month, i))
  22. .collect(Collectors.toList());
  23. }
  24. }
Success #stdin #stdout 0.09s 51752KB
stdin
Standard input is empty
stdout
2017-02-01
2017-02-02
2017-02-03
2017-02-04
2017-02-05
2017-02-06
2017-02-07
2017-02-08
2017-02-09
2017-02-10
2017-02-11
2017-02-12
2017-02-13
2017-02-14
2017-02-15
2017-02-16
2017-02-17
2017-02-18
2017-02-19
2017-02-20
2017-02-21
2017-02-22
2017-02-23
2017-02-24
2017-02-25
2017-02-26
2017-02-27
2017-02-28
=*==*==*=*=
2016-02-01
2016-02-02
2016-02-03
2016-02-04
2016-02-05
2016-02-06
2016-02-07
2016-02-08
2016-02-09
2016-02-10
2016-02-11
2016-02-12
2016-02-13
2016-02-14
2016-02-15
2016-02-16
2016-02-17
2016-02-18
2016-02-19
2016-02-20
2016-02-21
2016-02-22
2016-02-23
2016-02-24
2016-02-25
2016-02-26
2016-02-27
2016-02-28
2016-02-29