首页 > 其他 > 详细

常用类

时间:2019-06-16 00:02:03      阅读:132      评论:0      收藏:0      [点我收藏+]

一、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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!