给首页增加昨日和今年的金额统计接口

This commit is contained in:
季圣华
2022-05-23 23:47:58 +08:00
parent 8f3f05c0d3
commit 0b1540a86a
5 changed files with 118 additions and 42 deletions

View File

@@ -40,6 +40,40 @@ public class Tools {
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
/**
* 获取昨天的日期字符串
* @return
*/
public static String getYesterday(){
Date date=new Date();//取时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
//把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1表示昨天0表示今天)
calendar.add(Calendar.DATE,-1);
//这个时间就是日期往前推一天的结果
date=calendar.getTime();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
return formatter.format(date);
}
/**
* 获取当年的第一天
* @return
*/
public static String getYearBegin(){
String yearStr = new SimpleDateFormat("yyyy").format(new Date());
return yearStr + "-01-01";
}
/**
* 获取当年的最后一天
* @return
*/
public static String getYearEnd(){
String yearStr = new SimpleDateFormat("yyyy").format(new Date());
return yearStr + "-12-31";
}
/**
* 获取当前月 yyyy-MM
*