其他分享
首页 > 其他分享> > LocalDateTime 获取毫秒值本周开始时间和本周结束时间

LocalDateTime 获取毫秒值本周开始时间和本周结束时间

作者:互联网

获取long类型的毫秒值,本周开始时间和本周结束时间:

	/**
	 * @Description:本周的开始时间和结束时间
	 */
	public static Long[] getStartOrEndDayOfWeek() {
		LocalDate today = LocalDate.now();
		DayOfWeek week = today.getDayOfWeek();
		int value = week.getValue();
		LocalDate startDate = today.minusDays(value - 1);
		LocalDate endDate = today.plusDays(7 - value);
		LocalDateTime start = startDate.atStartOfDay().with(LocalTime.MIN);
		LocalDateTime end = endDate.atStartOfDay().with(LocalTime.MAX);
		Long startMillis = LDTUtils.getMillis(start);
		Long endMillis = LDTUtils.getMillis(end);
		return new Long[]{startMillis, endMillis};
	}

标签:value,Long,毫秒,本周,LocalDateTime,LocalDate,today
来源: https://blog.csdn.net/susu1083018911/article/details/123245095