Java code/**
* 取得上上季度最后一天日期
* @param date 日期
* @return
*/
public String getLastDay(Date date){
//取得日历
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 日历减6个月,即上上季度
calendar.add(Calendar.MONTH,-6);
int year = calendar.get(Calendar.YEAR);// 上上季度的年份
int mouth = calendar.get(Calendar.MONTH);// 上上季度的月份
String mmdd = "";// 月/日
// 根据月份,判断是哪个季度
switch( mouth){
case 1:
case 2:
case 3:
mmdd = "3/31"; // 第一季度最后一天是3/31
break;
case 4:
case 5:
case 6:
mmdd = "6/30"; // 第二季度最后一天是6/30
break;
case 7:
case 8:
case 9:
mmdd = "9/30";// 第三季度最后一天是9/30
break;
case 10:
case 11:
case 12:
mmdd = "12/31";// 第四季度最后一天是12/31
break;
}
String lastDate = String.valueOf(year) + "/" + mmdd;
System.out.println(lastDate);
return lastDate;
}