java.sql.Timestamp 类的使用

 时间:2024-11-02 13:09:16

1、获取当前时间:第一种:Timestamp now蟠校盯昂date1 = new Timestamp(System.艘早祓胂currentTimeMillis());System.out.println("System.currentTimeMillis():"+nowdate1);第二种:Date date = new Date();Timestamp nowdate2 = new Timestamp(date.getTime());System.out.println("new Date():"+nowdate2)

java.sql.Timestamp 类的使用

2、把String类型转换Timestamp:String datestr = "2002-01-29 04:37:21.453";Timestamp ts = Timestamp.valueOf(datestr);System.out.println(ts);

java.sql.Timestamp 类的使用

3、把Timestamp 类型转换String:SimpleDateFormat sdf = new Simpl髫潋啜缅eDateFormat("yyyy-MM-dd HH:mm:ss");Timestamp nowdate = new Timestamp(System.currentTimeMillis());String datestr = sdf.format(nowdate);System.out.println(datestr);

java.sql.Timestamp 类的使用
  • C#中如何判断字符串是否可以转换为数字?
  • android设置背景图片
  • NX 10.0怎么开启将剖面线角度限制在45度
  • IntelliJ IDEA怎么关闭显示文件扩展名
  • VC++6.0提示无法执行程序如何解决
  • 热门搜索
    节约从我做起手抄报 英雄人物手抄报 小学生感恩手抄报内容 初一手抄报 关于运动会的手抄报 关于春节的语文手抄报 历史手抄报花边 尊敬老人手抄报 关于交通安全手抄报 千字文手抄报