• System.currentTimeMillis()


    摘录:https://blog.csdn.net/qq_35661171/article/details/78839642

    System.currentTimeMillis()

    currentTimeMillis方法

    public static long currentTimeMillis()

    该方法的作用是返回当前的计算机时间,时间的表达格式为当前计算机时间和GMT时间(格林威治时间)1970年1月1号0时0分0秒所差的毫秒数。

    可以直接把这个方法强制转换成date类型。

    代码如下:

    import java.text.SimpleDateFormat;
    import java.util.Date;

    public class CurrentTime {
    public static void main(String[] args) {
    long timeMillis = System.currentTimeMillis();
    Date date = new Date(timeMillis);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日: HH:mm:ss");
    String newTime = sdf.format(date);
    System.out.println(newTime); //2018年08月27日: 14:27:28

    //os:Windows 7,user: sinosoft
    System.out.println("os:" + System.getProperty("os.name") + ",user: " + System.getProperty("user.name") );
    }
    }

    拼命敲
  • 相关阅读:
    xml的建模
    P1341 无序字母对
    P1330 封锁阳光大学
    P2661 信息传递
    P1312 Mayan游戏
    P1514 引水入城
    C. Sad powers
    P1195 口袋的天空
    P1821 [USACO07FEB]银牛派对Silver Cow Party
    P1396 营救
  • 原文地址:https://www.cnblogs.com/wuyuwuyueping/p/9542022.html
Copyright © 2020-2023  润新知