1.Integer转换成int的方法
Integer i = new Integer(10);
int k = i.intValue();
即Integer.intValue();
2.int转换成Integer
int i = 10;
Integer it = new Integer(i);
3.String转换成int的方法
String str = "10";
Integer
int
即:int
4.int转换成String
int i = 10;
(1)String s = String.valueOf(i);
(2)String s = Ingeger.toString(i);
(3)String s = "" + i;
5.String转换成Integer
String str = "10";
Integer it = Integer.valueOf(str);
6.Integer转换成String
Integer it = new Integer(10);
String str
7.String转换成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());
评论
# re: Java数据类型中String、Integer、int相互间的转换 2014-08-04 11:25 heh
6.Integer转换成String
Integer it;
String str = it.toString();
大哥你真有才。 这么恶心代码都能写出来 回复 更多评论
# re: Java数据类型中String、Integer、int相互间的转换[未登录] 2015-01-28 17:34 啊啊
@heh
哈哈 回复 更多评论
# 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();
} 回复 更多评论
# re: Java数据类型中String、Integer、int相互间的转换[未登录] 2015-08-20 16:59 123
hao 回复 更多评论
# re: Java数据类型中String、Integer、int相互间的转换 2016-01-12 11:10 jcc
@jcc
不好意思,看了下api,有这个方法,我可能是其他地方出问题了 回复 更多评论