1、int转换成String
int i = 123;
String str = String.valueOf(i);
2、String转换成int
String str = "123";
int i = Integer.valueOf(str);或者Integer.parseInt(str);
3、double转换成String
double d = 123.0d;
String str = String.valueOf(d);
4、String转换成double
String str = "123";
double d = Double.valueOf(str);
3、long转换成String
long l = 123.0l;
String str = String.valueOf(l);
4、String转换成double
String str = "123";
long l = Double.valueOf(str);
5.Calendar 转化 String
Calendar calendat = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String dateStr = sdf.format(calendar.getTime());
6.String 转化Calendar
String str="2013-07-31";
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
Date date =sdf.parse(str);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
7.Date 转化String
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
String dateStr=sdf.format(new Date());
8.String 转化Date
String str="2013-07-31";
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
Date date= sdf.parse(str);
9.Date 转化Calendar
Calendar calendar = Calendar.getInstance();
calendar.setTime(new java.util.Date());
10.Calendar转化Date
Calendar calendar = Calendar.getInstance();
java.util.Date date =calendar.getTime();
int i = 123;
String str = String.valueOf(i);
2、String转换成int
String str = "123";
int i = Integer.valueOf(str);或者Integer.parseInt(str);
3、double转换成String
double d = 123.0d;
String str = String.valueOf(d);
4、String转换成double
String str = "123";
double d = Double.valueOf(str);
3、long转换成String
long l = 123.0l;
String str = String.valueOf(l);
4、String转换成double
String str = "123";
long l = Double.valueOf(str);
5.Calendar 转化 String
Calendar calendat = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String dateStr = sdf.format(calendar.getTime());
6.String 转化Calendar
String str="2013-07-31";
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
Date date =sdf.parse(str);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
7.Date 转化String
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
String dateStr=sdf.format(new Date());
8.String 转化Date
String str="2013-07-31";
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
Date date= sdf.parse(str);
9.Date 转化Calendar
Calendar calendar = Calendar.getInstance();
calendar.setTime(new java.util.Date());
10.Calendar转化Date
Calendar calendar = Calendar.getInstance();
java.util.Date date =calendar.getTime();