Android Month String Get getCurMonthStr()

Here you can find the source of getCurMonthStr()

Description

get Cur Month Str

Declaration

public static String getCurMonthStr() 

Method Source Code

//package com.java2s;

import java.util.Calendar;

public class Main {

    public static String getCurMonthStr() {
        Calendar cal = Calendar.getInstance();
        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH) + 1;
        return getDate(year, month);
    }//from   ww  w  .j  av  a2  s  .  co  m

    public static String getDate(int year, int month) {
        String date = null;
        String a = String.valueOf(year);
        String b = String.valueOf(month);
        if (month > 9) {
            date = a + b;
        } else {
            date = a + "0" + b;
        }
        return date;
    }
}

Related

  1. getLastMonthStr()
  2. getMonthBefore(String format)
  3. getMonthString(int month, int abbrev)
  4. getMonthStringByIndex(int index)