Java Date to Month getMonth(java.util.Date date)

Here you can find the source of getMonth(java.util.Date date)

Description

get Month

License

Open Source License

Declaration

public static int getMonth(java.util.Date date) 

Method Source Code

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

import java.util.Calendar;

public class Main {
    public static int getMonth(java.util.Date date) {
        java.util.Calendar c = java.util.Calendar.getInstance();
        c.setTime(date);//from   w  w w.ja v a2s  .com
        return c.get(java.util.Calendar.MONTH) + 1;
    }

    public static String getMonth() {
        Calendar calendar = Calendar.getInstance();
        String month = String.valueOf(calendar.get(Calendar.MONTH) + 1);
        if (month.length() == 1) {
            month = "0" + month;
        }
        return month;
    }
}

Related

  1. getMonth(Date date)
  2. getMonth(Date dateParam)
  3. getMonth(Date... objects)
  4. getMonth(java.util.Date date)
  5. getMonth(java.util.Date date)
  6. getMonth(java.util.Date today)
  7. getMonth(long date, int increment)
  8. getMonth(String strDate)
  9. getMonthBeginDate()