取小时出来判断一下就知道了啊。可以切割或者使用Calendar类的方法。

解决方案 »

  1.   

    再来一个:SimpleDateFormat sdf2=new SimpleDateFormat("HH24");
    int hour = Integer.valueOf(sdf.format(dToday)).intValue();
    String welcome = null;if(hour>0&&hour<8) {
       welcome = "早上好"
    } ...当然,得到小时的方法很多,这个效率不高。
      

  2.   

    int hour = Integer.valueOf(sdf.format(dToday)).intValue();我试试,谢谢,开始把dToday当成String型
      

  3.   

    to:miles_z(www.2yup.com/asp/) ( )  <%
    java.util.Date dToday=new java.util.Date();
    SimpleDateFormat sdf2=new SimpleDateFormat("HH24");
    int hour = Integer.valueOf(sdf2.format(dToday)).intValue();
    String welcome = null;if(hour>0&&hour<18) {
       welcome = "baitianhao";
    }
    out.print(welcome);
    %>这样还是不行,显示  “null”
      

  4.   

    Date nowtime = new Date();
    int hour = nowtime.getHours();
    int minute = nowtime.getMinutes();
      

  5.   

    哦,错了。应该HH。楼上的getHours是Deprecated方法。如果一定要从date对象走,可以用calendar。HH24是什么?想不起来 :(