import java.util.*;
import java.text.*;
import java.sql.Timestamp;public class tsTest
{
public static void main(String[] args){
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Timestamp ts;
String dd = "20030820";
try{
d = sdf.parse(dd);
}catch(Exception e){
}
ts = new Timestamp(d.getTime());
System.out.println("ts is: "+ts);
}
};
//good luck

解决方案 »

  1.   

    DB2的timestamp么??似乎要精确到秒才可以。
    <%
    java.util.Date now = new java.util.Date(); 
    java.text.SimpleDateFormat formatter_time = new java.text.SimpleDateFormat("yyyyMMddkkmm"); 
    String now_time = formatter_time.format(now);
    %>
    <%=now_time%>
    //good luck
      

  2.   

    有没有象Integer.parseInt("")这样的
      

  3.   

    需要,没有像你所说的这种。不过你可以写成一个方法啊。
    public Timestamp getTS(String p0){
    Date d = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    Timestamp ts;
    try{
    d = sdf.parse(p0);
    }catch(Exception e){
    }
    ts = new Timestamp(d.getTime());
    return ts;
    }