Java Year Format toYYYYMM(Date date)

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

Description

to YYYYMM

License

Open Source License

Declaration

public static String toYYYYMM(Date date) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    public static String toYYYYMM(Date date) {
        return toYYYYMM(date, null);
    }/*ww  w  .j av  a2  s .  c o  m*/

    public static String toYYYYMM(Date date, TimeZone timezone) {
        if (date == null)
            throw new IllegalArgumentException("date is null.");
        if (timezone == null)
            timezone = TimeZone.getDefault();
        SimpleDateFormat dbFmt = new SimpleDateFormat("yyyyMM");
        dbFmt.setTimeZone(timezone);
        return dbFmt.format(date);
    }
}

Related

  1. isYearOnly(String input)
  2. isYYYY(String strDate)
  3. lastDayOfWeek(String year, int week, String format)
  4. stringYYYYmmDDhhMMssToDate(String value)
  5. toDateString(String ddMMMyyyy)
  6. toYYYYMMDD(Calendar cal)
  7. toYyyyMMddToDate(String date)
  8. unmarshalYYYYMMDD(String date)
  9. yyyyMMdd(Date date)