一、包装类
1、
2、Integer包装类的常用方法
3、基本类型和包装类之间相互转换
4、基本类型和字符串之间的转换
- 基本类型-》字符串:
int a = 10;
String str = a.toString();
String str = String.valueOf(a);
String str = a +"";
- 字符串-》基本类型:
String str= "8";
int d = Integer.parseInt(str);
ine c = Integer.valueOf(str);
二、Date 和 SimpleDateFormat类表示时间
1、使用 Date 类时需要导入 java.util 包,使用 SimpleDateFormat 时需要导入 java.text 包
扫描二维码关注公众号,回复:
2415945 查看本文章
- format()方法:将时间转换为指定的格式的字符串;
- parse()方法:将文本转化为日期;
三、calendar类:更便捷的时间日期处理类
Calendar c = Calendar.getInstance(); //创建Calendar对象
int year = c.get(Calendar.YEAR); // 获取当前年份
Date date = c.getTime(); //获取Date对象
Long time = c.getTimeInMillis(); //获取此Calendar的时间值