java类型转换

A.  char 转换String 

char c = 'a'; 
String str = String.valueOf(c);

B.整数 int 转换成字串 String 
1.) String s = String.valueOf(i);

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

3.) String s = "" + i;

C.int转换float

int f1 = 2;

float fl = (float100;

D.float转换int

float a=1.222f;

int b=(int)a;
 
 
 
E.int转换long
int a = 1;
long b = aL;
 
 
 
F.long转换int

long a = 10L;

int b = (int) a;

H.String转换Int

    String grandeId = "1237";

Integer.parseInt(gradeId);



 I.String 转换double

Double.parseDouble("project");

暂时写这些,遇到再补。

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");   //按照2018-04-08 13:08:24:456的格式输出时间
sdf.format(new Date());

What do you want to be?
原文地址:https://www.cnblogs.com/CatsBlog/p/8744362.html