Conversion between string, integer, and INT in Java Data Types
These conversions often make me dizzy. I simply found an article, which is quite clear at first glance. By the way, the article comes from:
Http://blog.sina.com.cn/cnxiaotao
1. Integer Conversion to int
Integer I;
Int K = I. intvalue ();
That is, integer. intvalue ();
2.int to integer
Int I;
Integer it = new INTEGER (I );
3. Convert string to int
String STR = "10 ";
IntegerIt = newInterger (STR );
IntI = it. intvalue ();
That is, intI = integer. intvalue (string );
4.int to string
Int I;
(1) string S = string. valueof (I );
(2) string S = ingeger. tostring (I );
(3) string S = "" + I;
5. Convert string to integer
String STR = "10"
Integer it = integer. valueof (STR );
6. Convert integer to string
Integer it;
String Str= It. tostring ();
7. Convert string to bigdecimal
Bigdecimal BD = new bigdecimal (STR );
8. Date
Calendar calendar = calendar. getinstance ();
Int year = calendar. Get (calendar. year );
Int month = calendar. Get (calendar. month) + 1;
Int day = calendar. Get (calendar. date );
// Obtain the date string of today
String today = java. Text. dateformat. getdateinstance (). Format (New java. util. Date ());
// Obtain the date of today
New java. SQL. Date (system. currenttimemillis ());