List of upcoming Six months including this month

i can get the current month in this format by

val dateFormat: SimpleDateFormat = new SimpleDateFormat("YYYYMM")
dateFormat.format(new Date())//201408

but how get

List(201408,201409,201410,201411,201412,201501)
Jon Skeet
people
quotationmark

(Java syntax, but I'm sure you can change it to Scala easily enough.)

In decreasing order of preference...

With Java 8:

// TODO: Which time zone are you interested in?
YearMonth yearMonth = YearMonth.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM");
List<String> dates = new ArrayList<>();
for (int i = 0; i < 6; i++) {
    dates.add(formatter.format(yearMonth.plusMonths(i)));
}

With Joda Time:

// TODO: Which time zone are you interested in?
YearMonth yearMonth = new YearMonth();
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMM");
List<String> dates = new ArrayList<>();
for (int i = 0; i < 6; i++) {
    dates.add(formatter.print(yearMonth.plusMonths(i)));
}

With Calendar:

// TODO: Which time zone are you interested in?
Calendar calendar = Calendar.getInstance();
DateFormat format = new SimpleDateFormat("yyyyMM");
List<String> dates = new ArrayList<>();
for (int i = 0; i < 6; i++) {
    dates.add(format.format(calendar.getTime()));
    calendar.add(Calendar.MONTH, 1);
}

people

See more on this question at Stackoverflow