Java Year Get getYearList(int years)

Here you can find the source of getYearList(int years)

Description

get Year List

License

Creative Commons License

Declaration

public static ArrayList<String> getYearList(int years) 

Method Source Code

//package com.java2s;
/*//  w  w w  .j  a v a 2 s  . co m
 * This software is in the public domain under CC0 1.0 Universal plus a
 * Grant of Patent License.
 *
 * To the extent possible under law, the author(s) have dedicated all
 * copyright and related and neighboring rights to this software to the
 * public domain worldwide. This software is distributed without any
 * warranty.
 *
 * You should have received a copy of the CC0 Public Domain Dedication
 * along with this software (see the LICENSE.md file). If not, see
 * <http://creativecommons.org/publicdomain/zero/1.0/>.
 */

import java.util.*;

public class Main {
    public static ArrayList<String> getYearList(int years) {
        ArrayList<String> yearList = new ArrayList<>(years);
        int startYear = Calendar.getInstance().get(Calendar.YEAR);
        for (int i = 0; i < years; i++)
            yearList.add(Integer.toString(startYear + i));
        return yearList;
    }
}

Related

  1. getYear(String tempdat, Locale locale)
  2. getYear(String[] contents)
  3. getYearCount(String from, String to)
  4. getYearEnd(Date date)
  5. getYearForDate(String dateToCheck, String pattern)
  6. getYearLongDesc(Date year)
  7. getYearlyIntervals(Date start, Date end)
  8. getYearName(String dateString)
  9. getYearsOfAge(Date birthDate, Date nowDate)