预约time时间格式化,并添加周信息
This commit is contained in:
parent
2d1e6f4b26
commit
bd8df3971c
|
@ -9,7 +9,9 @@ import java.text.ParseException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 时间工具类
|
||||
|
@ -203,7 +205,23 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
// 加上7天
|
||||
LocalDate sevenDaysLater = currentDate.plusDays(7);
|
||||
// 打印日期
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYY_MM_DD);
|
||||
return sevenDaysLater.format(formatter);
|
||||
}
|
||||
|
||||
public static String getWeek(Date date) {
|
||||
|
||||
LocalDate localDate = date.toInstant()
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDate();
|
||||
// 获取当前日期对应的星期几
|
||||
DayOfWeek dayOfWeek = localDate.getDayOfWeek();
|
||||
|
||||
// 打印英文的星期几
|
||||
System.out.println("Today is: " + dayOfWeek);
|
||||
|
||||
// 打印中文的星期几
|
||||
return dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.CHINA);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.dromara.scale.domain;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
@ -43,11 +44,13 @@ public class ReservationTime extends BaseEntity {
|
|||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.dromara.scale.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.scale.domain.ReservationDay;
|
||||
|
@ -37,7 +38,9 @@ public class ReservationDayVo implements Serializable {
|
|||
/**
|
||||
* 日期
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM-dd")
|
||||
private Date dayTime;
|
||||
private String week;
|
||||
|
||||
private List<ReservationTime> timeList;
|
||||
|
||||
|
|
|
@ -104,6 +104,8 @@ public class ReservationServiceImpl implements IReservationService {
|
|||
.between(ReservationDay::getDayTime, startTime, endTime)
|
||||
.eq(ReservationDay::getCounselorId, counselorId));
|
||||
for (ReservationDayVo one : dayList) {
|
||||
Date dayTime = one.getDayTime();
|
||||
one.setWeek(DateUtils.getWeek(dayTime));
|
||||
List<ReservationTime> timeList = timeMapper.selectList(new LambdaQueryWrapper<ReservationTime>()
|
||||
.eq(ReservationTime::getDayId, one.getId())
|
||||
.orderByAsc(ReservationTime::getStartTime));
|
||||
|
|
Loading…
Reference in New Issue