Sun Jan 23 00:15:08 +0000 2011 如果转化成timestamp 

解决方案 »

  1.   


    ic void test(){
    String str = "Sun Jan 23 00:15:08 +0000 2011";
    String fstr = "EEE MMM dd HH:mm:ss Z yyyy";
    SimpleDateFormat sdformat = new SimpleDateFormat(fstr,Locale.US);
    try {
    Date d =  null; 
    d = sdformat.parse(str);
    Timestamp ts = new Timestamp(d.getTime());
    System.out.println(sdformat.format(d));
    System.out.println(sdformat.format(ts)); 
    } catch (Exception e) {
    e.printStackTrace();
    }
      

  2.   

    String str = "Sun Jan 23 00:15:08 +0000 2011";
    DateFormat dateFormat;
    dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss Z yyyy", Locale.ENGLISH);
    java.util.Date timeDate = dateFormat.parse(str);
    java.sql.Timestamp dateTime = new java.sql.Timestamp(timeDate.getTime());