常用类

一、String、StringBuffer、StringBuilder

  String:字符串拼接方便、浪费内存;  StringBuffer:节省内存,只有一个中间量产生,线程安全
  StringBuilder:线程不安全
  StringBuffe.append();添加

二、Math

  abs绝对值、次方、平方、开平方、最大值、最小值、平均值、求和、随机数(random)
  Math.random();  //0-1不包括1

三、Random
    Random r = new Random();
    r.nextInt(); // -21亿 ~ +21亿
    r.nextBoolean();// false true
    r.nextInt(10); // 0~9
    // 1 ~ 100
    int i = r.nextInt(100) + 1;

四、时间类

  Date日期、DateFormat时间格式化、Calendar日历(推算时间)
  yMdh Hmse
  long -->Date  :  new Date(long);
  new Date();  //获取当前时间
  Date  --> long   :  getTime();
  DateFormat(抽象类,子类:SimpleDateFormat)用构造方法规定格式。
  Date  -->String  :format(Date);
  String  -->Date  :parse(String);

五、时间

  计算机时间:从~到现在的毫秒值
  0点:1970-1-1 0:00:00  格林威治天文台 GMT
  (UTC 世界原子钟时间)

原文地址:https://www.cnblogs.com/leizz/p/11029230.html