public String getTotalMonth(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
String s = sdf.format(date);
return s;
}
/**
* 获取当前月份
*
* @return
*/
public String getCurrentMonth() {
String month = this.getTotalMonth(new Date());
return month;
}
/**
* 获取当月第一天
*
* @return
*/
public String getCurrentMonthFirstDay() {
StringBuilder sb = new StringBuilder();
sb.append(this.getCurrentMonth() + "-01");
return sb.toString();
}
/**
* 获取上月第一天
*
* @return
*/
public String getPreMonthFirstDay() {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
String berforeFirstDay = df.format(calendar.getTime());
return berforeFirstDay;
}
JFinal框架时间相关的使用
最新推荐文章于 2023-11-14 14:44:57 发布