• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generate list of months and years  RSS feed

 
Alberto Garrido
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I need to generate an arraylist of months with the year, but it needs to be specific months and if a month started then it should be added. For example, now we are in march, so the list needs to be like this:

June 2016
July 2016
February 2017
June 2017
July 2017


When june begin the list should be:


July 2016
February 2017
June 2017
July 2017
February 2018


and etc.

How can it be done, with LocalDate (Java 1.8) if possible?

Thanks.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Have you looked over the documentation for LocalDate (←click that, it's a link) to see if it has a way to do some calculations for months? I can't really deduce what your rules are for including a month in the list but you can definitely use one of the methods that LocalDate provides to do part of the work that you need to do.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!