fork(1) 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.text.*;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14.  
  15. int year = 2017;
  16. String month = "February";
  17. SimpleDateFormat format = new SimpleDateFormat("yyyy/MMMM", Locale.US);
  18. Date utilDate = format.parse(year + "/" + month);
  19. //get first day of your month
  20. System.out.println(new SimpleDateFormat("yyyy/MM/dd").format(utilDate));
  21.  
  22. //get days of months
  23. Calendar cal = Calendar.getInstance();
  24. cal.setTime(utilDate);
  25. int monthMaxDays = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
  26. //loop and add a day to your date
  27. for (int i = 0; i < monthMaxDays - 1; i++) {
  28. cal.add(Calendar.DATE, 1);
  29. System.out.println(new SimpleDateFormat("yyyy/MM/dd").format(cal.getTime()));
  30. }
  31.  
  32.  
  33. }
  34. }
Success #stdin #stdout 0.09s 4386816KB
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