zoukankan      html  css  js  c++  java
  • java 经验

    1.获取时间

    long begin=System.currentTimeMillis();//单位毫秒
    long end=System.nanoTime();//单位纳秒
    Date d = new Date();
    long longtime = d.getTime();
    System.out.println(longtime);
    String time = d.toLocaleString();
    System.out.println(time);//标准格式时间





    2.String和int互转

    (1)int to string

    int ->String
    int i= 10;
    String s = ""+10;//利用java中的‘+’连接符。
    //或者利用Integer的toString方法。String s = new Integer(i).toString();

    (2) string to int

    String ->int
    String s = "123";
    int i = Integer.parseInt(s);//利用java中int基本类型的封装类Integer的parseInt方法。

    3.java 模仿c宏定义

    写一个接口,定义数据类型static final,然后用类实现。

    4.写入文件

     try {
    //打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
    FileWriter writer = new FileWriter(fileName, true);
    writer.write(content);
    writer.close();
    } catch (IOException e) {
    e.printStackTrace();





  • 相关阅读:
    docker-compose
    获取时区
    maven插件
    jquery_ui_api中文
    sax xpath读取xml字符串
    Ant打包
    [转]html5音乐播放器
    javax mail网址
    vbscript调用fso
    fso查找被删除的文件
  • 原文地址:https://www.cnblogs.com/phoenix13suns/p/2337578.html
Copyright © 2011-2022 走看看