Java Date to Month getMonthOfYear(Date dt)

Here you can find the source of getMonthOfYear(Date dt)

Description

Get and return the month of year from the given Date dt

License

Open Source License

Parameter

Parameter Description
dt The given Date

Return

day The int value for month of year

Declaration

public static int getMonthOfYear(Date dt) 

Method Source Code

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

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    /**// w  w w . ja v  a 2  s .c  o  m
     * Get and return the month of year from the given Date dt
     * 
     * @param dt
     *            The given Date
     * 
     * @return day The int value for month of year
     */
    public static int getMonthOfYear(Date dt) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(dt);
        return (cal.get(Calendar.MONTH));
    }
}

Related

  1. getMonthName(Date date)
  2. getMonthOfCurrentTime(Date date)
  3. getMonthOffset(Date sourceDate, Date targetDate)
  4. getMonthOfThisYear(Date currentdate)
  5. getMonthOfYear(Date date)
  6. getMonthOfYear(final Date date)
  7. getMonthRate(Date date, boolean moveIn)
  8. getMonths(Date date1, Date date2)
  9. getMonthStart(Date date)