public class GetTimeString {
private static SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd");
private static Calendar calendar = Calendar.getInstance();
//获取近一周时间点
public static String getNearWeek() {
calendar.setTime(new Date());
calendar.add(Calendar.DATE, -7);
Date d = calendar.getTime();
return dateFormater.format(d);
}
//获取近一月时间点
public static String getNearMonth() {
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, -1);
Date m = calendar.getTime();
return dateFormater.format(m);
}
//获取近半年时间点
public static String getNearHalfYear() {
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, -6);
Date m = calendar.getTime();
return dateFormater.format(m);
}
}