当前位置:编程学习 > JAVA >>

为啥Oracle里的Date类型的时间,读不出时分秒呀

create table TBL_MESSAGE
(
  ID           NUMBER,
  NOTE         VARCHAR2(100),
  SENDUNAME    VARCHAR2(20),
  RECEIVEUNAME VARCHAR2(20),
  POSTTIME     DATE default SYSDATE,
  READSIGN     NUMBER
)
建表信息,POSTTIME格式例如2011/11/30 11:00:01用JAVA取时间
public class Message {
public Message(){}
public Message(int id,String note,String sendUname,String receiveUname
,Date postTime,int readSign){
this.id = id;
this.note = note;
this.sendUname = sendUname;
this.receiveUname = receiveUname;
this.postTime = postTime;
this.readSign = readSign;
}
private int id;
private String note;
private String sendUname;
private String receiveUname;
private Date postTime;
private int readSign;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public String getPostTime() {
SimpleDateFormat formater = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
String strCurrentTime = formater.format(postTime);
return strCurrentTime;
}
public void setPostTime(Date postTime) {
this.postTime = postTime;
}
可是在调用类的getPostTime方法,在网页上显示的只有日期,没有时分秒。伤肺,求高人~ --------------------编程问答-------------------- 不要用date,用timestamp 这个可以精确到毫秒 --------------------编程问答-------------------- rs.getDate => rs.getTimestamp

应该是你获取记录返回时候就弄丢了 --------------------编程问答-------------------- POSTTIME TIMESTAMP default SYSDATE,
--------------------编程问答-------------------- 用smalldate --------------------编程问答-------------------- timestamp --------------------编程问答-------------------- timestamp 对。用这个就可以。 --------------------编程问答-------------------- timestamp
--------------------编程问答-------------------- 用varchar2 --------------------编程问答-------------------- 唉 楼主问的问题 楼下有几个能正确回答的啊 都说了date类型 偏要让人改成timestamp。唉
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,