如果当前时间等于下午 6 点或下午 6 点之后并且不在第二天午夜和早上 6 点之间,我想将布尔值 isBasePriceTime 设置为 false。但是,如果当前时间是下午 2 点,它会继续将 isBasePriceTime 设置为 false。
private boolean checkCurrentTimePriceType()
{
/*Get the current price type depending on the time of the day the user wants to
get a cab */
Calendar today = Calendar.getInstance();
Date currentDate = today.getTime();
//creates a time for 6pm
String nightPriceFullTime = "18:00:00";
Date nightPriceTime = java.sql.Time.valueOf(nightPriceFullTime);
Calendar nightPriceDateCalendar = Calendar.getInstance();
nightPriceDateCalendar.setTime(nightPriceTime);
//creates a time for midnight
String nightPriceFullTimeMidnight = "00:00:00";
Date nightPriceTimeMidnight = java.sql.Time.valueOf(nightPriceFullTimeMidnight);
Calendar nightPriceMidnightDateCalendar …
Run Code Online (Sandbox Code Playgroud)