Java Year Month getPerMonthByCuttentYear()

Here you can find the source of getPerMonthByCuttentYear()

Description

get Per Month By Cuttent Year

License

Apache License

Declaration

public static List<String> getPerMonthByCuttentYear() 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class Main {
    private static SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");

    public static List<String> getPerMonthByCuttentYear() {
        String year = getCurrentYear();
        //      String year = "2013";
        Calendar a = Calendar.getInstance();
        int month = a.get(Calendar.MONTH) + 1;
        List<String> months = new ArrayList<String>();
        for (int i = month; i > 0; i--) {
            //         if(i!=8 && i!=9 && i!=10 && i!=11)
            months.add(year + "-" + String.format("%02d", i));
        }//  ww  w.  j  a  v a  2 s.c  o m
        return months;
    }

    public static String getCurrentYear() {
        return yearFormat.format(new Date());
    }
}

Related

  1. getFirstDayOfMonth(int year, int month, Integer day)
  2. getFirstTimeOfDay(int year, int month, int day)
  3. getFirstYearMonth()
  4. getMonthDays(Integer year, Integer month)
  5. getMonthDays(Integer year, Integer month)
  6. getQuarterToYearMonthDay(Integer year, Integer quarter)
  7. getStartMonth(int year, int month)
  8. getTheLastDayOfTheMonth(int year, int month)
  9. getThisYearMonth()