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