Java數(shù)據(jù)類(lèi)型中String、Integer、int相互間的轉(zhuǎn)換

          1.Integer轉(zhuǎn)換成int的方法

          Integer i = new Integer(10); 
          int k = i.intValue();
          即Integer.intValue();

           

          2.int轉(zhuǎn)換成Integer

          int i = 10;

          Integer it = new Integer(i);

           

          3.String轉(zhuǎn)換成int的方法

          String str = "10";  
          Integer it = new Interger(str);  

          int i = it.intValue();  

          即:int i = Integer.intValue(string);

           

          4.int轉(zhuǎn)換成String

          int i = 10;

          (1)String s = String.valueOf(i);

          (2)String s = Ingeger.toString(i);

          (3)String s = "" + i;

           

          5.String轉(zhuǎn)換成Integer

          String str = "10";

          Integer it = Integer.valueOf(str);

           

          6.Integer轉(zhuǎn)換成String

          Integer it = new Integer(10);

          String str = it.toString();

           

          7.String轉(zhuǎn)換成BigDecimal

          BigDecimal bd = new BigDecimal(str);

           

          8.日期

          Calendar calendar = Calendar.getInstance();
          int year = calendar.get(Calendar.YEAR);
          int month = calendar.get(Calendar.MONTH)+1;
          int day = calendar.get(Calendar.DATE);

          //獲取今天的日期字符串
          String today = java.text.DateFormat.getDateInstance().format(new java.util.Date());
          //獲取今天的日期
          new java.sql.Date(System.currentTimeMillis());

          posted on 2011-02-28 14:12 小羅 閱讀(118523) 評(píng)論(5)  編輯  收藏

          評(píng)論

          # re: Java數(shù)據(jù)類(lèi)型中String、Integer、int相互間的轉(zhuǎn)換 2014-08-04 11:25 heh

          6.Integer轉(zhuǎn)換成String

          Integer it;

          String str = it.toString();

          大哥你真有才。 這么惡心代碼都能寫(xiě)出來(lái)  回復(fù)  更多評(píng)論   

          # re: Java數(shù)據(jù)類(lèi)型中String、Integer、int相互間的轉(zhuǎn)換[未登錄](méi) 2015-01-28 17:34 啊啊

          @heh
          哈哈  回復(fù)  更多評(píng)論   

          # protected void onProgressUpdate(integer... values) { //int value = values[0].intValue(); progress.setProgress(); } 2015-08-17 14:21 顏靜

          protected void onProgressUpdate(integer... values) {
          //int value = values[0].intValue();
          progress.setProgress();

          }  回復(fù)  更多評(píng)論   

          # re: Java數(shù)據(jù)類(lèi)型中String、Integer、int相互間的轉(zhuǎn)換[未登錄](méi) 2015-08-20 16:59 123

          hao   回復(fù)  更多評(píng)論   

          # re: Java數(shù)據(jù)類(lèi)型中String、Integer、int相互間的轉(zhuǎn)換 2016-01-12 11:10 jcc

          @jcc
          不好意思,看了下api,有這個(gè)方法,我可能是其他地方出問(wèn)題了  回復(fù)  更多評(píng)論   


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


          網(wǎng)站導(dǎo)航:
           
          <2014年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿

          隨筆分類(lèi)

          隨筆檔案

          文章分類(lèi)

          文章檔案

          相冊(cè)

          收藏夾

          Web Framework

          常上的技術(shù)網(wǎng)站

          查找資料的java網(wǎng)站

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 微山县| 拉孜县| 灵石县| 密山市| 綦江县| 德阳市| 肃北| 酒泉市| 恭城| 黔江区| 兴宁市| 滦南县| 丹凤县| 蒙山县| 临安市| 澎湖县| 射阳县| 贡嘎县| 大丰市| 武功县| 海盐县| 贵港市| 阿拉善左旗| 太仓市| 常德市| 沙雅县| 关岭| 绥芬河市| 冷水江市| 葵青区| 五家渠市| 巩留县| 固阳县| 崇礼县| 衢州市| 阿拉善盟| 阳城县| 宽城| 遂溪县| 鹰潭市| 乡宁县|