Java中怎么比较当前时间在9点半和15点之间
发布网友
发布时间:2022-06-07 05:35
我来回答
共2个回答
热心网友
时间:2023-10-16 08:22
Date now = new Date();
int hours = now.getHours();
int minutes = now.getMinutes();
System.out.println(hours + " " + minutes);
if ((hours == 9 && minutes >= 30) || (hours >= 10 && hours < 15))
{
System.out.println("9:30 - 15:00");
}
热心网友
时间:2023-10-16 08:22
Date d = new Date();
int hours = d.getHours();
if(hours>9 and hours<15)
{
ok
}