Java Month Format formatMonth(final int year, final int month)

Here you can find the source of formatMonth(final int year, final int month)

Description

format Month

License

Open Source License

Parameter

Parameter Description
year a parameter
month 0-11

Return

"yyyy-mm"

Declaration

public static String formatMonth(final int year, final int month) 

Method Source Code

//package com.java2s;
// ProjectForge is dual-licensed.

public class Main {
    /**/*  w  w  w. j a v a  2s . com*/
     * @param year
     * @param month 0-11
     * @return "yyyy-mm"
     */
    public static String formatMonth(final int year, final int month) {
        final StringBuffer buf = new StringBuffer();
        buf.append(year);
        if (month >= 0) {
            buf.append('-');
            final int m = month + 1;
            if (m <= 9) {
                buf.append('0');
            }
            buf.append(m);
        }
        return buf.toString();
    }
}

Related

  1. addMonths(String src, int addMonth, String format)
  2. formatMonth(Date date)
  3. formatMonth(Date date)
  4. formatMonth(final Date date)
  5. formatMonth(int month)
  6. formatMonth(int month, Locale locale, boolean longFormat)
  7. formatMonth(String dateOrign)
  8. formatMonthDay(int decimal)