查询时间段内所有日期(限foton)

String dataStr = "2019-04";
try {
Date date = DateUtils.parseDate(dataStr);
Date startTime = DateUtils.getStartTime(DateUtils.DateType.MONTHLY, date, null);
Date endTime = DateUtils.getEndTime(DateUtils.DateType.MONTHLY, date);
Pair<Date , Date> pair = null;
Iterator<Pair<Date , Date>> iterator = DateUtils.getIterator(startTime, endTime, DateType.DAILY, false);
while(iterator.hasNext()){
pair = iterator.next();
System.out.println("startTime:" + DateUtils.toString(pair.getKey(),DateUtils.DEFAULT_DATE_TIME_FORMAT) + "____endTime:" + DateUtils.toString(pair.getValue(),DateUtils.DEFAULT_DATE_TIME_FORMAT));
}
} catch (ParseException e) {
e.printStackTrace();
}

  

转载于:https://www.cnblogs.com/charkey/p/10953253.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的汽车租赁系统的代码实现,包含了上述要求: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>汽车租赁系统</title> <style> .container { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 20px; } .vehicle { margin-right: 20px; margin-bottom: 20px; width: 200px; height: 200px; border: 1px solid black; text-align: center; cursor: pointer; } .vehicle:hover { background-color: lightgray; } .details { margin-top: 10px; text-align: center; } .form { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 300px; height: 200px; border: 1px solid black; background-color: white; text-align: center; display: none; } .form h3 { margin-top: 20px; } .form input { margin-top: 20px; } .form button { margin-top: 20px; } </style> </head> <body> <div class="container"> <button id="loadBtn">加载车辆信息</button> </div> <div class="form"> <h3>请输入租用天数</h3> <input type="number" id="daysInput" placeholder="请输入天数"> <button id="confirmBtn">确定</button> </div> <script> // 定义车辆类 class Vehicle { constructor(brand, rent) { this.brand = brand; this.vno = `粤B${Math.floor(Math.random() * 10000).toString().padStart(4, '0')}`; this.rent = rent; } calcRent(days) { return days * this.rent; } } // 定义轿车类 class Car extends Vehicle { constructor(brand, rent, type) { super(brand, rent); this.type = type; } } // 定义客车类 class Bus extends Vehicle { constructor(brand, rent, seat) { super(brand, rent); this.seat = seat; } } // 定义货车类 class Truck extends Vehicle { constructor(brand, rent, weight) { super(brand, rent); this.weight = weight; } } // 创建一些示例车辆 const car1 = new Car('Toyota', 200, 'Camry'); const car2 = new Car('Honda', 180, 'Accord'); const bus1 = new Bus('Yutong', 300, 50); const bus2 = new Bus('Higer', 280, 40); const truck1 = new Truck('Dongfeng', 400, 10); const truck2 = new Truck('Foton', 380, 8); // 将车辆添加到数组中 const vehicles = [car1, car2, bus1, bus2, truck1, truck2]; // 获取DOM元素 const loadBtn = document.getElementById('loadBtn'); const form = document.querySelector('.form'); const daysInput = document.getElementById('daysInput'); const confirmBtn = document.getElementById('confirmBtn'); // 加载车辆信息 loadBtn.addEventListener('click', () => { const container = document.querySelector('.container'); container.innerHTML = ''; for (let vehicle of vehicles) { const div = document.createElement('div'); div.classList.add('vehicle'); div.innerHTML = `<h4>${vehicle.brand}</h4><p>${vehicle.vno}</p>`; div.addEventListener('mouseover', () => { const details = document.createElement('div'); details.classList.add('details'); details.innerHTML = `<p>日租金:${vehicle.rent}元</p>`; if (vehicle instanceof Car) { details.innerHTML += `<p>型号:${vehicle.type}</p>`; } else if (vehicle instanceof Bus) { details.innerHTML += `<p>座位数:${vehicle.seat}</p>`; } else if (vehicle instanceof Truck) { details.innerHTML += `<p>载重量:${vehicle.weight}吨</p>`; } div.appendChild(details); }); div.addEventListener('mouseout', () => { const details = div.querySelector('.details'); if (details) { div.removeChild(details); } }); div.addEventListener('click', () => { form.style.display = 'block'; confirmBtn.addEventListener('click', () => { const days = Number(daysInput.value); if (isNaN(days) || days <= 0) { alert('请输入有效天数'); } else { const rent = vehicle.calcRent(days); alert(`租用${vehicle.brand},共${days}天,费用为${rent}元`); form.style.display = 'none'; daysInput.value = ''; } }); }); container.appendChild(div); } loadBtn.style.display = 'none'; }); </script> </body> </html> ``` 这个系统通过创建Vehicle、Car、Bus、Truck四个类来实现不同类型的车辆,并在页面上展示它们的品牌、车牌、日租金等基本信息。当鼠标悬停在某个车辆上时,会显示出该车辆的详细信息,包括型号、座位数或载重量。当点击某个车辆时,会弹出一个输入框,询问租用天数,并计算出费用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值