fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.time.*;
  8. import java.time.format.*;
  9. import java.time.temporal.*;
  10.  
  11. /* Name of the class has to be "Main" only if the class is public. */
  12. class Ideone
  13. {
  14. public static void main (String[] args) throws java.lang.Exception
  15. {
  16.  
  17. String input = "2017 February";
  18. DateTimeFormatter f = DateTimeFormatter.ofPattern ( "uuuu MMMM" , Locale.US );
  19. YearMonth ym = YearMonth.parse ( input , f );
  20.  
  21. System.out.println ( "===== Days of " + ym + " =====" );
  22. for ( int i = 1 ; i <= ym.lengthOfMonth () ; i ++ ) {
  23. LocalDate localDate = ym.atDay ( i );
  24. System.out.println ( localDate );
  25. }
  26. System.out.println ( "=================" );
  27.  
  28. System.out.println ( "input: " + input );
  29. System.out.println ( "ym.toString(): " + ym );
  30.  
  31. }
  32. }
Success #stdin #stdout 0.17s 4386816KB
stdin
Standard input is empty
stdout
===== Days of 2017-02 =====
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
=================

input: 2017 February
ym.toString(): 2017-02