三元运算符有什么问题?在java中

时间:2019-11-19 07:54:49

标签: java

下面的API将布尔值返回为false?但是它应该返回值True。原因是什么?  在行三元运算符上放置调试光标时,将无法找到它。请指导  调试方法和解决方案的方法。

  public void isTrueOrFalse(){
            System.out.println("format for the new Date() core API = "+new Date() instanceof String);
            System.out.println("format for the new Date() core API = "+new Date());
            /*Date d=new Date(2016,11,20);*/
            /*Date d1=new Date(2016,11,20);*/
            /*System.out.println(d);*/

            DateFormat formatter= new SimpleDateFormat("dd/MM/yyyy");
            Date d1=new Date();
            Date todayWithoutTimeZone;
            try {
                todayWithoutTimeZone = formatter.parse(formatter.format(d1));
                System.out.println("something check="+todayWithoutTimeZone);
                System.out.println("condition check "+todayWithoutTimeZone.equals("Tue Nov 19 00:00:00 IST 2019"));
                boolean checkTest = todayWithoutTimeZone.equals("Tue Nov 19 00:00:00 IST 2019") ? true : false;


                logger.info("returned checked Status"+checkTest);


            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

1 个答案:

答案 0 :(得分:5)

for Ci in Cs:
    print(Ci.flags)

todayWithoutTimeZone.equals("Tue Nov 19 00:00:00 IST 2019") todayWithoutTimeZone。它永远不会等于Date