Here you can find the source of stringToMonth(String year, String month, boolean flag)
public static Date stringToMonth(String year, String month, boolean flag)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static Date stringToMonth(String year, String month, boolean flag) { if (year == null || month == null) return null; Calendar instance = Calendar.getInstance(); if (flag) { instance.set(Integer.parseInt(year), Integer.parseInt(month) - 1, 1, 0, 0, 0); } else {//from w w w . j av a 2s . c o m instance.set(Integer.parseInt(year), Integer.parseInt(month), 1, 0, 0, 0); } return instance.getTime(); } }