Java Month Get getMonth(Date dt)

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

Description

Get month string for the specified date.

License

Open Source License

Parameter

Parameter Description
dt Specified date.

Return

The month string of specified date

Declaration

public static String getMonth(Date dt) 

Method Source Code

//package com.java2s;
/*//from   w  w  w .jav  a  2 s  . com
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
 *
 * The contents of this file are subject to the terms of the Common 
 * Development and Distribution License ("CDDL")(the "License"). You 
 * may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the License at
 * https://open-dm-mi.dev.java.net/cddl.html
 * or open-dm-mi/bootstrap/legal/license.txt. See the License for the 
 * specific language governing permissions and limitations under the  
 * License.  
 *
 * When distributing the Covered Code, include this CDDL Header Notice 
 * in each file and include the License file at
 * open-dm-mi/bootstrap/legal/license.txt.
 * If applicable, add the following below this CDDL Header, with the 
 * fields enclosed by brackets [] replaced by your own identifying 
 * information: "Portions Copyrighted [year] [name of copyright owner]"
 */

import java.util.Date;

import java.text.FieldPosition;
import java.text.SimpleDateFormat;

public class Main {
    /**
     * Get month string for the specified date.
     *
     * @param dt Specified date.
     * @return The month string of specified date
     */
    public static String getMonth(Date dt) {

        SimpleDateFormat sdf = new SimpleDateFormat("MMMM");
        StringBuffer sb = new StringBuffer();
        sdf.format(dt, sb, new FieldPosition(0));

        return sb.toString();
    }
}

Related

  1. getMonth(Date date)
  2. getMonth(Date date)
  3. getMonth(Date date)
  4. getMonth(Date date)
  5. getMonth(Date date, TimeZone timeZone)
  6. getMonth(Date theDate)
  7. getMonth(int i)
  8. getMonth(int i)
  9. getMonth(int month)