N天前开始时间
/* N天前开始时间
* 1 == 昨天
* 2 == 前天
* 3 == 以此类推
*/
public static long NumberOfDaysStartUnixTime(int NumberOfDays ) {
Calendar calendar = Calendar.getInstance();
calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH)-NumberOfDays,0,0,0);
long yesterdayStart = calendar.getTimeInMillis();
return yesterdayStart;
}
N天前结束时间
/* N天前结束时间
* 1 == 昨天
* 2 == 前天
* 3 == 以此类推
*/
public static long NumberOfDaysEndUnixTime(int NumberOfDays) {
Calendar calendar = Calendar.getInstance();
calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH)-NumberOfDays,23,59,59);
long yesterdayEnd = calendar.getTimeInMillis();
return yesterdayEnd;
}
网友评论