java获取时间格式

来源:互联网 发布:欢乐购接单软件下载 编辑:程序博客网 时间:2024/05/22 15:36
 public static Timestamp getDate(){
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  Timestamp time = Timestamp.valueOf(sdf.format(new Date()));
  return time;
 }
public static void main(String[] args) {
 Timestamp t = getDate();
 System.out.println(t.toString());
}
原创粉丝点击