oracle trunc函數(shù)日期 oracle中如何獲得當(dāng)前的系統(tǒng)時間?
oracle中如何獲得當(dāng)前的系統(tǒng)時間?兩種方法1.在數(shù)據(jù)庫直接用oracle的當(dāng)前系統(tǒng)時間函數(shù)sysdate。想精確到秒的話可以在sql中這樣寫to_char(sysdate,"yyyy/mm/ddh
oracle中如何獲得當(dāng)前的系統(tǒng)時間?
兩種方法
1.在數(shù)據(jù)庫直接用oracle的當(dāng)前系統(tǒng)時間函數(shù)sysdate。想精確到秒的話可以在sql中這樣寫
to_char(sysdate,"yyyy/mm/ddhh24:mi")
2.在web程序中獲取時間,插入數(shù)據(jù)庫。
Datedate=newDate()
SimpleDateFormatsd=newSimpleDateFormat("yyyy-MM-ddHH:mm:ss")
Stringnow=sd.format(date)
System.out.println(now)
//這里的now是String型的。如果想獲要date型的,直接System.out.println(date)