常用类及其方法应用

Math类(计算)、Arrays类(排序等)、BigInteger类(精确整数)、BigDecimal类(精确浮点数)

----------------------------------------------------------------------------------------------------------------

Integer类

    将String类型转换为int类型:

     (方式1):   int i=Integer.parseInt(s);

     (方式2):  String-->Integer-->int 

                   Integer.valueOf(s).intValue();

   将int类型转换为String类型

                  String s=String.valueOf(i);

--------------------------------------------------------------------------------------------

Character类

   判断功能:

        1. isDigit(char ch): 是否是数字

        2. isUpperCase(char ch):是否是大写

        3. isLowerCase(char ch):是否是小写

----------------------------------------------------------------------------------

System类

     System.exit(0):正常终止虚拟机;

     System.currentTimeMillis():主要用于记录一段代码运行的时间

-------------------------------------------------------------------------------------

DateFormat类

   一、 format(Date d):把Date类型转换为String类型

    实现代码:new SimpleDateFormat(format).format(d);

   二、 parse(String date):把String类型转换为Date类型

    实现代码:new SimpleDateFormat(format).parse(date);

----------------------------------------------------------------------------------------

 SimpleDateFormat:

    构造方法:Public SimpleDateFormat(String format)

                  其中format就是转换的格式

ps:SimpleDateFormat extends DateFormat

  --------------------------------------------------------------------------------------

Date:

    1.从一个Date得到毫秒值(可以用作id)

          long time=new Date().getTime();

   2.从一个毫秒值转换为Date

          Date d1=d.setTime(time);

原文地址:https://www.cnblogs.com/yuefeng123/p/7336908.html