我们可以从给定的时段中选择任何时间。如果选择的时间比当前时间少1小时,那么我们必须显示警报。以下是我写的。但它并不完全正确。在某些情况下它可以正常工作
select count(*),
case when age >= 50 then '50 and older' when age < 50 and age >= 35 then '35 to 49' else 'Under 35' end as AgeCat,
count(*)/sum(count(*)) over (partition by '') as percent
from mydata group by 2;
答案 0 :(得分:0)
使用Date
在SimpleDateFormat
课程中转换deliveryDateTime。
防爆。
try {
if (currentDate.equals(DeliveryDate)) {
String deliveryTime = "1:00 PM";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
"hh:mm a", Locale.ENGLISH);
java.util.Date currentDate = simpleDateFormat.parse(deliveryTime);
Calendar curDate= Calendar.getInstance();
curDate.setTime(currentDate);
Calendar currentDateDelivery= Calendar.getInstance();
currentDateDelivery.set(Calendar.HOUR_OF_DAY,
curDate.get(Calendar.HOUR_OF_DAY));
currentDateDelivery.set(Calendar.MINUTE,
curDate.get(Calendar.MINUTE));
Calendar threeHoursLaterTime = Calendar.getInstance();
threeHoursLaterTime.add(Calendar.HOUR_OF_DAY, 3);
if (currentDateDelivery.getTimeInMillis() < threeHoursLaterTime
.getTimeInMillis()) {
showToast(
"Sorry! Delivery Time is less than 3 hours.Cannot place order");
}
}
} catch (Exception e) {
e.printStackTrace();
}