import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class Monthstartend {
// 获取当前月的第一天
public static String getMonthStart(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//用来获取当前时间
Calendar calendar = new GregorianCalendar();
calendar.set(Calendar.DAY_OF_MONTH, 1);
String start = sdf.format(calendar.getTime());
return start;
}
//获取当前月的最后一天
public static String getMonthEnd(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//用来获取当前时间
Calendar calendar = new GregorianCalendar();
calendar.add(Calendar.MONTH, 1);
calendar.set(Calendar.DAY_OF_MONTH, 0);
String end = sdf.format(calendar.getTime());
return end;
}
}