Here you can find the source of getMonthFirstDay(String date)
public static Date getMonthFirstDay(String date)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date getMonthFirstDay(String date) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); Date d = null;/*from w ww .ja v a 2s . co m*/ try { d = format.parse(date); } catch (Exception e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (d != null) { cal.setTime(d); } cal.add(Calendar.DAY_OF_MONTH, 0); return cal.getTime(); } }