/***
* 获取本周的第一天和最后一天:
*/
public static String getFirstDayAndLastDayOfDay() {
StringBuffer stringBuffer=new StringBuffer();
SimpleDateFormat dateFormater = new SimpleDateFormat(
"yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, 1);
cal.getTime();
stringBuffer.append(dateFormater.format(cal.getTime()) + "");
cal.set(Calendar.DAY_OF_WEEK,
cal.getActualMaximum(Calendar.DAY_OF_WEEK));
stringBuffer.append("-"+dateFormater.format(cal.getTime()));
return stringBuffer.toString();
}
/**
* 获取本月的第一天和最后一天:
* @return
*/
public static String getFirstDayAndLastDayOfMonth() {
StringBuffer stringBuffer=new StringBuffer();
SimpleDateFormat dateFormater = new SimpleDateFormat(
"MM-dd");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.getTime();
stringBuffer.append(dateFormater.format(cal.getTime()) + "");
cal.set(Calendar.DAY_OF_MONTH,
cal.getActualMaximum(Calendar.DAY_OF_MONTH));
stringBuffer.append("-"+dateFormater.format(cal.getTime()));
return stringBuffer.toString();
}
/**
* 获取本年的第一天和最后一天:
*
* @return
*/
public static String getFirstDayAndLastDayOfYear() {
StringBuffer stringBuffer=new StringBuffer();
SimpleDateFormat dateFormater = new SimpleDateFormat(
"yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_YEAR, 1);
cal.getTime();
stringBuffer.append(dateFormater.format(cal.getTime()) + "");
cal.set(Calendar.DAY_OF_YEAR,
cal.getActualMaximum(Calendar.DAY_OF_YEAR));
stringBuffer.append("-"+dateFormater.format(cal.getTime()));
return stringBuffer.toString();
}
如果觉得《android获取后一天日期 android获取本周本月本年的第一天和最后一天》对你有帮助,请点赞、收藏,并留下你的观点哦!