Here you can find the source of getMonthFirstDay()
public static Date getMonthFirstDay() throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date getMonthFirstDay() throws ParseException { int mondayPlus; Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.set(Calendar.DAY_OF_MONTH, 1); return getDate(cal.getTime()); }/*from w w w .j a v a2 s. c om*/ public static Date getDate(Date date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { return sdf.parse(sdf.format(date)); } catch (ParseException e) { return null; } } public static Date getDate(Date date, String dateFormat) { SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); try { return sdf.parse(sdf.format(date)); } catch (ParseException e) { return null; } } public static Date getDate(String date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { return sdf.parse(date); } catch (ParseException e) { return null; } } public static Date getDate(String date, String dateFormat) { SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); try { return sdf.parse(date); } catch (ParseException e) { return null; } } public static Date getTime(String date) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.parse(date); } }