*/
public void showYearDate(int pos) {
if(pos ==0){ //本年
Calendar curYearCalendar = Calendar.getInstance();
curYear = curYearCalendar.get(Calendar.YEAR);
}
else if(pos ==1){ //下个年
curYear +=1;
}
else { //上个年
curYear -=1;
}
String startday = curYear + "-01-01";
String endday = curYear + "-12-31";
timeStr = startday + "至" + endday;
tvTime.setText(timeStr);
}
/**
* 获取该季度的第一天和最后一天
* @param pos 0当前季度 1 下个季度 -1 上个季度
*/
public void showQuaterDate(int pos) {
if(pos ==0){ //本季度
curQuaterCalender = Calendar.getInstance();
int month = curQuaterCalender.MONTH;
int stMonth =0;
if(month >=0 && month<=3){
stMonth =0;
}
else if(month >=4 && month<=8){
stMonth =4;
}
else{
stMonth =9;
}
curQuaterCalender.set(Calendar.MONTH, stMonth);
}
else if(pos ==1){ //下季度
curQuaterCalender.add(Calendar.MONTH,3);
}
else { //上季度
curQuaterCalender.add(Calendar.MONTH,-3);
}
curQuaterCalender.set(Calendar.DATE,1);//得到该月第一天
String startday = formatter.format(curQuaterCalender.getTime());
Calendar tempDate = Calendar.getInstance();
tempDate.set(Calendar.YEAR, curQuaterCalender.get(Calendar.YEAR));
tempDate.set(Calendar.MONTH, curQuaterCalender.get(Calendar.MONTH)+3);
tempDate.set(Calendar.DAY_OF_MONTH, curQuaterCalender.get(Calendar.DAY_OF_MONTH));
tempDate.roll(Calendar.DATE, -1);
String endday = formatter.format(tempDate.getTime());
timeStr = startday + "至" + endday;
tvTime.setText(timeStr);
}