public static String parseTimestampToStr(Timestamp time) {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    formatter.format(time);
    return formatter.format(time);
  }

解决方案 »

  1.   

    Calendar now = Calendar.getInstance();
         String yyyy = String.valueOf(now.get(java.util.Calendar.YEAR));
         String mm = String.valueOf(now.get(Calendar.MONTH) + 1);
         String dd = String.valueOf(now.get(Calendar.DAY_OF_MONTH));
         String hh = String.valueOf(now.get(Calendar.HOUR_OF_DAY));
         String ff = String.valueOf(now.get(Calendar.MINUTE));
         String ss = String.valueOf(now.get(Calendar.SECOND));
         mm = (1==mm.length()) ? ("0"+mm) : mm;
         dd = (1==dd.length()) ? ("0"+dd) : dd;
         hh = (1==hh.length()) ? ("0"+hh) : hh;
         ff = (1==ff.length()) ? ("0"+ff) : ff;
         ss = (1==ss.length()) ? ("0"+ss) : ss;
        String timeStamp = new StringBuffer(mm).append(dd).append(hh).append(ff).append(ss).toString();
      

  2.   

    String           toString() format a timestamp in JDBC timestamp escape format
    static Timestamp valueOf(String s) converts a string object in JDBC timestamp
                     escape format to a Timestamp value
      

  3.   

    那怎么把字符串“Tue Sep 02 09:54:46 CST 2003”变成date对象
      

  4.   

    simpleDateFormat sdf = new simpleDateFormat("EEE MMM DD hh:mm:ss z yyyy");
    Date d = new Date();
    d = sdf.format(“Tue Sep 02 09:54:46 CST 2003”);//I didn't test, good luck!