Here you can find the source of getYearMonth()
public static long getYearMonth()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long getYearMonth() { return getYearMonth(new Date()); }//from w w w . ja v a2 s . com public static long getYearMonth(Date date) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMM"); String str = dateFormat.format(date); return Long.parseLong(str); } public static String format(Date date, String p) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(p); return simpleDateFormat.format(date); } }