我写的用sql语句取时间,可老报驱动有问题,下面的话:
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriverj
va.lang.NullPointerException
叫我好恼心呀!

解决方案 »

  1.   

    用System.currentTimeMillis()可不对呀,高手请指点下。
      

  2.   

    System.out.println(new Date().toLocaleString());  // deprecated
      

  3.   

    直接掉 java.util.Date 不行? 或者 java.util.Calendar
      

  4.   

    <%=new java.util.Date().toLocaleString()%>
      

  5.   

    你是在SQL里执行System.currentTimeMillis()肯定不对了,上面提示是找不到相关的类.
    还有System.currentTimeMillis()返回的是一个以毫秒生成的long数字,你到底要实现什么样的功能,把代码片断贴点出来.
      

  6.   

    Calendar cal=new Calendar();
    Timestamp today=new Timestamp(cal.getTimeInMillis());
    System.out.println(today);orDate today=new Date();
    System.out.println(today);
      

  7.   

    public String getServerTime(String format) { if (format == null)
    format = "yyyy-MM-dd hh:mm:ss"; Sql = "select getdate() as serverTime"; try {
    stmt = cnn.createStatement();
    rs = stmt.executeQuery(Sql);
    if (rs.next())
    return new SimpleDateFormat(format).format(rs
    .getTimestamp("serverTime"));
    else
    throw new SQLException();
    } catch (SQLException e) {
    e.printStackTrace();
    JOptionPane.showMessageDialog(null, "获取系统时间时发生错误,请与管理员联系!", "错误",
    JOptionPane.ERROR_MESSAGE);
    DBConnection.logoff();
    return null;
    }
    }
    我想楼主的意思是获取服务器时间吧,本地时间获取有个鬼用啊,右下角看一眼不就知道了,用我的吧,不但能获取时间,还能格式化成你想要的格式
    变量自己定义一下,再引入包,再把我这个程序copy过去,直接可以用了