sql中用to_char(字段名,'yyyy-mm-dd')

解决方案 »

  1.   

    ora中有个直接的转化方法,用法是select to_char(fieldname,'yyyy-MM-dd') as XXX from tablename ;或者也可以在java中用SimpleDateFormat类的format方法来处理,不过还是用第一种比较方便
      

  2.   

    java.sql.Date date//date为取出来的日期数据.
    String date=new SimpleDateFormat("yyyy-MM-dd").format(date);
    out.println(date);
      

  3.   

    上面第2个变量定义错误了!
    java.sql.Date date//date为从数据库取出来的日期数据.
    String strDate=new SimpleDateFormat("yyyy-MM-dd").format(date);
    out.println(strDate);
      

  4.   

    if your get the data from the database which is a object of java.util.Date
    then perform like the following
    String result=new SimpleDateFormat("yyyy-MM-dd").format(date);if the data is a String
    then like this
    String result=date.substring(0,date.indexOf(" ")-1);
      

  5.   

    用subString把后面不要的给截了
      

  6.   

    String strDate=new SimpleDateFormat("yyyy-MM-dd").format(date);
    out.println(strDate);