package com.ibeetl.admin.flow.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class MonthDate {

	SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
	
	//上月第一天
	public String lastMonthStart(){
		Calendar   cal_1=Calendar.getInstance();//获取当前日期 
		cal_1.add(Calendar.MONTH, -1);
		cal_1.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天 
		String firstDay = format.format(cal_1.getTime());
		System.out.println("-----1------firstDay:"+firstDay);
		return firstDay;
	}
	
	//上月最后一天
	public String lastMonthEnd(){
		//获取前月的最后一天
		Calendar cale = Calendar.getInstance();   
		cale.set(Calendar.DAY_OF_MONTH,0);//设置为1号,当前日期既为本月第一天 
		String lastDay = format.format(cale.getTime());
		System.out.println("-----2------lastDay:"+lastDay);
		return lastDay;
	}
	
	//前两月第一天
	public String twoMonthStart(){
		Calendar   cal_2=Calendar.getInstance();//获取当前日期 
		cal_2.add(Calendar.MONTH, -2);
		cal_2.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天 
		String firstDay2 = format.format(cal_2.getTime());
		System.out.println("-----1------firstDay:"+firstDay2);
		return firstDay2;
	}
	
	//前两月最后一天
	public String twoMonthEnd(){
		Calendar cale2 = Calendar.getInstance(); 
		cale2.add(Calendar.MONTH, -1);
		cale2.set(Calendar.DAY_OF_MONTH,0);//设置为1号,当前日期既为本月第一天 
		String lastDay2 = format.format(cale2.getTime());
		System.out.println("-----2------lastDay:"+lastDay2);
		return lastDay2;
	}
	
	

}
