小编Dan*_*Kay的帖子

根据 Java 和 Android Studio 中的特定时间检查当前时间

如果当前时间等于下午 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)

java time boolean date android-studio

2
推荐指数
1
解决办法
4874
查看次数

标签 统计

android-studio ×1

boolean ×1

date ×1

java ×1

time ×1