posts - 15,  comments - 34,  trackbacks - 27

          SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd"); //格式化當(dāng)前系統(tǒng)日期
          qds.setDate("制單日期", Date.valueOf(dateFm.format(new java.util.Date())));

          此種情況數(shù)據(jù)庫(kù)的字段為Date型

          ------------------------------------------------------------------------------------------------------------

          String 制單日期 = MessageFormat.format("{0,date,yyyy-MM-dd HH:mm:ss}", new Object[] { new java.sql.Date(System.currentTimeMillis()) });
          qds.setTimestamp("制單日期", Timestamp.valueOf(制單日期)); // 不能強(qiáng)行轉(zhuǎn)換

          此種情況數(shù)據(jù)庫(kù)的字段為Timestamp(6)型

          ---------------------------------------------------------------------------------------------------------

          附:幾個(gè)Date類的valueOf()方法

          1. java.sql.Date.valueOf(java.lang.String)

              public static Date valueOf(String s)
           Converts a string in JDBC date escape format to a Date value.

           Parameters:
           s - a String object representing a date in in the format "yyyy-mm-dd"
           Returns:
           a java.sql.Date object representing the given date
           Throws:
           IllegalArgumentException - if the date given is not in the JDBC date escape format (yyyy-mm-dd)

          2. java.sql.Time.valueOf(java.lang.String)

              public static Time valueOf(String s)
           Converts a string in JDBC time escape format to a Time value.

           Parameters:
           s - time in format "hh:mm:ss"
           Returns:
           a corresponding Time object

          3. java.sql.Timestamp.valueOf(java.lang.String)
            
             public static Timestamp valueOf(String s)
           Converts a String object in JDBC timestamp escape format to a Timestamp value.

           Parameters:
           s - timestamp in format yyyy-mm-dd hh:mm:ss.fffffffff
           Returns:
           corresponding Timestamp value
           Throws:
           IllegalArgumentException - if the given argument does not have the format yyyy-mm-dd hh:mm:ss.fffffffff



          本文引用通告地址: http://blog.csdn.net/jwbecalm/services/trackbacks/444843.aspx
          posted on 2005-08-28 05:26 jacky 閱讀(1938) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          <2005年8月>
          31123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          常用鏈接

          留言簿(10)

          隨筆檔案

          文章分類

          文章檔案

          相冊(cè)

          收藏夾

          java

          搜索

          •  

          最新評(píng)論


          主站蜘蛛池模板: 砚山县| 方山县| 阿拉尔市| 昔阳县| 斗六市| 南漳县| 宜兰市| 磴口县| 龙山县| 天峻县| 德格县| 开江县| 兴安县| 楚雄市| 大荔县| 济源市| 建德市| 墨江| 云龙县| 淅川县| 平阳县| 古浪县| 应用必备| 德昌县| 宁海县| 宣威市| 漳平市| 水城县| 虹口区| 策勒县| 唐河县| 宜兰市| 苏州市| 洞口县| 璧山县| 乐都县| 治多县| 金塔县| 会宁县| 凤山市| 正宁县|