一、Arrays类
1.把指定整型数组转换成字符串。
public static String toString(int[] a);
2.对指定数组进行升序排序。
public static void sort(int[] a);
【tips】:工具类的设计思想:(1)构造方法用private修饰,防止外界创建对象。(2)成员用static修饰,直接使用类名访问方法。

二、基本类型包装类
1.基本数据类型各自对应的包装类:
    除int对应Integer、char对应Character外,其他基本数据类型对应的包装类只需把首字母大写。
2.Integer类的使用
(1)静态方法获取对象
//public static Integer valueOf(int i)
Integer i=Integer.valueOf(100);

//public static Integer valueOf(String s)
Integer i=Integer.valueOf("100");
(2)int与String类型的相互转换
    1)int→String:
    方式1:字符串拼接:
String s=""+a;
    方式2:
public static String valueOf(int a) String s=String.valueOf(100);
    2)String→int:
方式1:String→Integer→int
Integer i = Integer.valueOf(s); int a = i.intValue();
方式2:String直接→int
 int a = Integer.parseInt(s);
(3)自动装箱和拆箱
    1)装箱:基本数据类型→包装类类型
    2)拆箱:包装类类型→基本数据类型
    3)自动装箱:
Integer i = 100;
    4)自动拆箱:
i += 100;

三、日期类
1.Date类
(1)构造方法:
//Date类两个常用的构造方法 Date d = new Date();//此时d代表当前的日期时间。 long time = 1000 * 60 * 60; //1小时 Date d = new Date(time); //此时d代表纪元时间(1970.1.1 00:00:00)后的time毫秒的时间。 
(2)常用方法
    1)public long getTime()
long time = d.getTime(); //d.getTime():返回从Date对象d代表的时间到纪元时间的毫秒值。
    2)public void setTime(long time)
d.setTime(time);//d.setTime(long time):返回将Date对象d设置为纪元时间后的time毫秒的时间。
2.SimpleDateFormat类
(1)构造方法
SimpleDateFormat sdf = new SimpleDateFormat();//默认模式和时间格式 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd HH:mm:ss"); //20220427 22:03:58 
(2)日期格式化(format)和解析(perse)
    1)格式化:Date→String:
String s = sdf.format(Date d);
    2)解析:String→Date:
String s = "2022/4/27 22:02:05";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");//这里指定的日期格式要与字符串中的一致 Date d = sdf.parse(String s);
【注意】:解析时,创建SDF对象时的日期格式要与给定字符串中的一样。
3.Calendar(日历类)
(1)public static Calendar getInstance():用于获取Calendar对象,其日历字段已用当前日期和时间格式化。
Calendar c = Calendar.getInstance();
(2)public int get (int field):返回指定日历字段的int值。
int year = c.get(Calendar.YEAR);
【tips】:日历字段中的月份Calendar.MONTH是从0开始的,也就是说这里的月份为0~11!!!
(3)public abstract void add(int field,int amount):根据日历规则,将指定日历字段(field)加或减给定的时间量(amount)。
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, -1);//把日历往前推一天
(4)public final void set(int year,int month,int date):设置当前日历的年月日
Calendar c = Calendar.getInstance();
c.set(2022, 2, 1);//将日历的当前时间设置为2022年3月1日。
【tips】:想知道y年的m月有多少天,就把日历设置(set)成该年的m+1月1日,再把日历往前推(add)一天就是m月的最后一天,获取(get)这天并输出即可。