Commit 76be6753 by zhengxj

finish 新增获取过去日期方法 on 20190128 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17175 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent e74c2de1
......@@ -599,18 +599,30 @@ public class DateUtil {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
return df.format(calendar.getTime());
}
/**
* 得到上个月的第一天
*/
public static String getLastMonthFirstDay() {
//上个月第一天
GregorianCalendar gcLast = (GregorianCalendar) Calendar.getInstance();
gcLast.setTime(new Date());
gcLast.add(Calendar.MONTH, -1);
gcLast.set(Calendar.DAY_OF_MONTH, 1);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
return df.format(gcLast.getTime());
}
/**
* 得到过去数个月的第一天日期
*/
public static String getPastMonthFistDay(Integer pastMonth) {
public static Date getPastMonthFistDay(Integer pastMonth) {
//上个月最后一天
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -pastMonth); //加一个月
calendar.set(Calendar.DATE, 1); //设置为该月第一天
// calendar.add(Calendar.DATE, -1); //再减一天即为上个月最后一天
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
return df.format(calendar.getTime());
return calendar.getTime();
}
......@@ -626,30 +638,7 @@ public class DateUtil {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
return calendar.getTime();
}
/**
* 得到上个月的第一天
*/
public static Date getLastMonthFirstDay() {
//上个月第一天
GregorianCalendar gcLast = (GregorianCalendar) Calendar.getInstance();
gcLast.setTime(new Date());
gcLast.add(Calendar.MONTH, -1);
gcLast.set(Calendar.DAY_OF_MONTH, 1);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
return gcLast.getTime();
}
/**
* 得到指定日期上个月的第一天
*/
public static String getLastMonthFirstDay(Date date) {
//上个月第一天
GregorianCalendar gcLast = (GregorianCalendar) Calendar.getInstance();
gcLast.setTime(new Date());
gcLast.add(Calendar.MONTH, -1);
gcLast.set(Calendar.DAY_OF_MONTH, 1);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
return df.format(gcLast.getTime());
}
/**
* 获取上周一的日期
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!