zoukankan      html  css  js  c++  java
  • 常用类及其方法应用

    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);

  • 相关阅读:
    软工写文档熟练使用word很重要——自动生成编号
    UML——类图
    软件开发模型
    UML基础(终极总结)
    想买一款笔记本戴尔的InspironTM 6400
    ASP.NET 2.0 Enter Key Default Submit Button
    使用.net备份和还原数据库
    GridView导出Excel研究
    使用c#建立虚拟目录
    OpacityMask
  • 原文地址:https://www.cnblogs.com/yuefeng123/p/7336908.html
Copyright © 2011-2022 走看看