|
@@ -13,10 +13,10 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Random;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
@@ -69,7 +69,23 @@ public class ReserveOvertimeServiceImpl implements ReserveOvertimeService {
|
|
|
reserveOvertime.setCreatTime(new Date());
|
|
|
reserveOvertime.setReserveKey(result);
|
|
|
reserveOvertimeDao.insert(reserveOvertime);
|
|
|
- return BaseResult.okData(result);
|
|
|
+ // 将Date转换为LocalDateTime
|
|
|
+ LocalDateTime localDateTime = handleTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
+ // 定义输出的格式
|
|
|
+ DateTimeFormatter outputFormatterFull = DateTimeFormatter.ofPattern("yyyy年MM月dd日HH点");
|
|
|
+ DateTimeFormatter outputFormatterHour = DateTimeFormatter.ofPattern("HH点");
|
|
|
+ // 格式化原始时间
|
|
|
+ String startTimeStr = localDateTime.format(outputFormatterFull);
|
|
|
+ // 增加1小时
|
|
|
+ LocalDateTime updatedTime = localDateTime.plusHours(1);
|
|
|
+ // 格式化增加后的时间,只保留小时部分
|
|
|
+ String endTimeStr = updatedTime.format(outputFormatterHour);
|
|
|
+ String time = startTimeStr + "至" + endTimeStr;
|
|
|
+ //返回前端数据
|
|
|
+ Map<Object, Object> map = new HashMap<>();
|
|
|
+ map.put("ReserveKey", result);
|
|
|
+ map.put("time",time);
|
|
|
+ return BaseResult.ok(map);
|
|
|
}
|
|
|
|
|
|
private static String getTime() {
|