Java Month Get getMonth(Date date, TimeZone timeZone)

Here you can find the source of getMonth(Date date, TimeZone timeZone)

Description

get Month

License

Open Source License

Declaration

public static int getMonth(Date date, TimeZone timeZone) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    private static final SimpleDateFormat _fmtMonth = new SimpleDateFormat("MM");

    public static int getMonth(Date date, TimeZone timeZone) {
        if (date == null)
            throw new IllegalArgumentException("date is required.");
        if (timeZone == null)
            timeZone = TimeZone.getDefault();
        _fmtMonth.setTimeZone(timeZone);
        try {//  ww w  . ja  v  a 2 s.  c om
            return Integer.parseInt(_fmtMonth.format(date));
        } catch (NumberFormatException e) {
            throw new IllegalStateException("Failed to format date : " + e.getMessage());
        }
    }
}

Related

  1. getMonth(Date date)
  2. getMonth(Date date)
  3. getMonth(Date date)
  4. getMonth(Date date)
  5. getMonth(Date date)
  6. getMonth(Date dt)
  7. getMonth(Date theDate)
  8. getMonth(int i)
  9. getMonth(int i)