package org.bamboo.util;
import java.text.SimpleDateFormat;
import java.util.Calendar;
/**
* 时间操作类
* @author MIKE
*
*/
public class TimeUtilities {
/**
* 获取当前月里边的第一天
*
* @return 第一天
*/
public static String getFristDayOfMonth(){
String day="";
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar=Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH, 1);
System.out.println(calendar.getTime());
day=format.format(calendar.getTime());
return day;
}
/**
* 获取当前月里边的最后一天
*
* @return 最后一天
*/
public static String getLastDayOfMonth(){
String day="";
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar=Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.add(Calendar.MONDAY, 1);
calendar.add(Calendar.DAY_OF_MONTH, -1);
day=format.format(calendar.getTime());
return day;
}
public static void main(String [] args){
System.out.println(getFristDayOfMonth());
System.out.println(getLastDayOfMonth());
}
}