Java Year Current getCurrentYearMonth()

Here you can find the source of getCurrentYearMonth()

Description

get Current Year Month

License

Apache License

Declaration

public static String getCurrentYearMonth() 

Method Source Code

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

import java.util.Calendar;

public class Main {

    public static String getCurrentYearMonth() {
        int year = getCurrentYear();
        int month = getCurrentMonth();
        String yearMonth = "";
        if (month >= 10) {
            yearMonth = String.valueOf(year) + String.valueOf(month);
        } else {/*from w  w  w  .  j  a  v a 2 s .  c o m*/
            yearMonth = String.valueOf(year) + "0" + String.valueOf(month);
        }
        return yearMonth;
    }

    public static int getCurrentYear() {
        Calendar cal = Calendar.getInstance();
        // return cal.getTime().getYear()+1900;
        return cal.get(Calendar.YEAR);

    }

    public static int getCurrentMonth() {
        Calendar cal = Calendar.getInstance();
        return cal.get(Calendar.MONTH) + 1;
    }
}

Related

  1. getCurrentYear()
  2. getCurrentYear()
  3. getCurrentYear()
  4. getCurrentYear()
  5. getCurrentYearFirst()
  6. getCurrentYearMonthDay()
  7. getCurrYear()
  8. getCurrYearFirst()
  9. getLastDayOfCurrentYear()