Oracle時間格式化問題

來源:互聯網
上載者:User

在上班的時候發現orcale的時間格式化和Java的時間格式化有點區別:

例如Java中見一個日期改成時分的格式的字串可以這樣寫:

SimpleDateFormat sdf = new SimpleDateFormat();

sdf.format("2011-02-27 20:51:03",''HH:MM:ss");

輸出的結果是:20:51:03

orcale的時間格式化成字元函數是:to_char

如果按照Java的格式話樣式寫:to_char('2011-02-27 20:51:03','hh:mm:ss');

輸出的結果就是:8:01:03,明顯不是正確的結果

這樣寫就能輸出正確的結果:to_char('2011-02-27 20:51:03','hh24:mi:ss');

輸出的結果:20:51:03

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.