java String類型轉 java.sql.time類型


String[] timePhase = reservationRuleInDTO.getTimePhase().split(",");
List<ReservationTimeRule> reservationTimeRuleList = new ArrayList<>();
for(int i =0;i<timePhase.length;i++){
reservationTimeRule = new ReservationTimeRule();
if(timePhase[i]!=null){
Date d = format.parse(timePhase[i]);
Time time = new Time(d.getTime());
reservationTimeRule.setStartTime(time);
}

時間的大小的比較
SimpleDateFormat  ymdFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat hmsFormat = new SimpleDateFormat("HH:mm:ss");
// DateFormat d3 = DateFormat.getTimeInstance();
// 當前時段+間隔時間(之后再說)
String nowTimes = hmsFormat.format(new Date());
if(reservationRule != null && reservationRule.getStatus()==1){
// 給前端返回時段列表(獲取當期時間判斷所能預約的時段)
List<ReservationTimeRule> reservationTimeRules = timeRuleMapper.selectTimeByReservationId(reservationRule.getId());
List<ReservationTimeRule> reservationTimeRuleList= new ArrayList<>();
for (ReservationTimeRule reservationTimeRule :reservationTimeRules) {
String sdTimes = reservationTimeRule.getStartTime().toString();
if (hmsFormat.parse(sdTimes).getTime() > hmsFormat.parse(nowTimes).getTime()){
reservationTimeRuleList.add(reservationTimeRule);
}
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM