时间工具类修改
parent
caa57c1d5d
commit
37bab876b3
|
@ -776,6 +776,25 @@ public class TimeUtils {
|
|||
return dayBegin - daysDiffer * DAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得当前时间之前下一个星期几的0点时间
|
||||
* @param now
|
||||
* @param targetWeekday
|
||||
* @return
|
||||
*/
|
||||
public static long getNextWeekdayStartTime(long now, int targetWeekday) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(now);
|
||||
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
|
||||
int daysDiffer = dayOfWeek - targetWeekday;
|
||||
if (daysDiffer < 0) {
|
||||
daysDiffer = daysDiffer + DAYOFWEEK_CARDINALITY;
|
||||
}
|
||||
|
||||
long dayBegin = getBeginOfDay(now);
|
||||
return dayBegin + daysDiffer * DAY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取系统当前默认时区与指定时区的时间差.(单位:毫秒)
|
||||
|
|
Loading…
Reference in New Issue