Here you can find the source of toYYYYMM(Date date)
public static String toYYYYMM(Date date)
//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); } }