Java Month of Year currentYearMonth()

Here you can find the source of currentYearMonth()

Description

current Year Month

License

Open Source License

Declaration

public static int currentYearMonth() 

Method Source Code


//package com.java2s;

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

public class Main {
    private static final String YYYYMMINTFORMAT = "yyyyMM";

    public static int currentYearMonth() {
        Calendar c = Calendar.getInstance();
        return formatDateIntValue(c.getTime(), YYYYMMINTFORMAT);
    }/*ww w.ja v  a  2  s  .c o m*/

    private static int formatDateIntValue(Date updateTime, String dateIntFormat) {
        return Integer.parseInt(formatStr(updateTime, dateIntFormat));
    }

    public static String formatStr(Date date, String dateFormat) {
        return new SimpleDateFormat(dateFormat).format(date).toString();
    }
}

Related

  1. create(final int year, final int month, final int day)
  2. create(int year, int month, int day)
  3. create(int year, int month, int day, int hour, int minute, int second)
  4. createKey(int instance, int year, int month, int day, int hour, int min, int sec, int milli, String uuid, boolean rolling)
  5. createTimestamp(int year, int month, int day, int hour, int minutes, int seconds)
  6. dayOfYear(int year, int month, int day)
  7. dayOfYear(int year, int month, int day)
  8. daysInMonth(final int month, final int year)
  9. daysInMonth(final int year, final int month)