Java Month Get getMonth()

Here you can find the source of getMonth()

Description

get Month

License

Open Source License

Declaration

public static String getMonth() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public final static String MM = "MM";
    public final static String YYYY_MM_DD = "yyyy-MM-dd";

    public static String getMonth() {
        return format(getCurrDate(), MM);
    }// w ww. ja  v a2s . c  om

    public static String format(Date date, String pattern) {
        if (date == null)
            return "";
        else
            return getFormatter(pattern).format(date);
    }

    public static String format(Date date) {
        if (date == null)
            return "";
        else
            return getFormatter(YYYY_MM_DD).format(date);
    }

    public static synchronized Date getCurrDate() {
        Calendar calendar = Calendar.getInstance();
        return calendar.getTime();
    }

    private static SimpleDateFormat getFormatter(String parttern) {
        return new SimpleDateFormat(parttern);
    }
}

Related

  1. getIntevalMonth(String strDate1, String strDate2)
  2. getMonth()
  3. getMonth()
  4. getMonth()
  5. getMonth()
  6. getMonth()
  7. getMonth()
  8. getMonth()
  9. getMonth()