Java Year Format formatYyyyMm(Date date)

Here you can find the source of formatYyyyMm(Date date)

Description

Formats a date object to "YYYYMM".

License

LGPL

Parameter

Parameter Description
date a parameter

Declaration

public static String formatYyyyMm(Date date) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /** DateFormat for "YYYYMM". */
    public static DateFormat formatYyyyMm() {
        return new SimpleDateFormat("yyyyMM");
    }//from w  w  w. java 2  s  .  c o m

    /**
     * Formats a date object to "YYYYMM".
     * @param date
     * @return
     */
    public static String formatYyyyMm(Date date) {
        if (date == null) {
            return "";
        }
        return formatYyyyMm().format(date);
    }
}

Related

  1. formatUniversalMonthYear(Date date)
  2. formatYear(Date d, Locale locale)
  3. formatYear(Date date)
  4. formatYear(Date date)
  5. formatYearMonth(Date date)
  6. formatyyyyMMddHHmmss(long time)
  7. get_Oracle_DateString_YYYYMMdd_HHmmss(java.util.Date date)
  8. getDDMMYYY_HHMM()
  9. getDDMMYYYYDate(Date date)