Here you can find the source of getFirstDate(String yearMonthStr, String yearMonthFormat, String dateFormat)
public static String getFirstDate(String yearMonthStr, String yearMonthFormat, String dateFormat) throws Exception
//package com.java2s; import java.text.*; public class Main { public static String getFirstDate(String yearMonthStr, String yearMonthFormat, String dateFormat) throws Exception { DateFormat dfYearMonth = new SimpleDateFormat(yearMonthFormat); DateFormat dfDate = new SimpleDateFormat(dateFormat); java.util.Date date;/* w w w.j a v a2 s . c o m*/ if (yearMonthStr == null || yearMonthStr.equals("")) { throw new Exception(yearMonthStr + " is invalid."); } try { date = dfYearMonth.parse(yearMonthStr); } catch (ParseException e) { throw new Exception(yearMonthStr + " is invalid."); } return dfDate.format(date); } }