Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.text.SimpleDateFormat; public class Main { public static String getCurrentMonth() { Calendar calendar = Calendar.getInstance(); long currentTime = calendar.getTimeInMillis(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); calendar.setTimeInMillis(currentTime); return formatter.format(calendar.getTime()); } }