Here you can find the source of getFirstDay(boolean withTime)
public static String getFirstDay(boolean withTime)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static String getFirstDay(boolean withTime) { String formatStr = "yyyy-MM-dd"; if (withTime) { formatStr += " HH:mm:ss"; }//w ww . java 2s.co m Calendar cal = Calendar.getInstance(); SimpleDateFormat datef = new SimpleDateFormat(formatStr); cal.set(GregorianCalendar.DAY_OF_MONTH, 1); Date beginTime = cal.getTime(); return datef.format(beginTime); } }