zoukankan      html  css  js  c++  java
  • java 获取当前时间(年月日时分秒)

    获取当前时间(年月日时分秒)

    Date d = new Date();
    SimpleDateFormat sbf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    System.out.println(sbf.format(d));
    或
    System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    
    
    2020-04-28 14:23:05

    获取当前时间戳 到毫秒

    System.out.println(System.currentTimeMillis());
    
    1588055609783

    时间戳换成年月日

    Date date = new Date(System.currentTimeMillis());
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    String format = dateFormat.format(date);
    System.out.println(format);
    
    
    1588055609783 --> 2020-04-28 02:33:29

    年月日换成时间戳

    leDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = simpleDateFormat.parse("2020-04-28 02:33:29");
    long ts = date.getTime();
    System.out.println(ts);
    String res = String.valueOf(ts);  // 转化为字符串
    System.out.println(res);
    
    1588012409000
    

      

      

      

  • 相关阅读:
    Spherical Harmonic Lighting
    EV/ISO/Stop
    opengles dither
    rgb颜色空间到xyz空间的映射
    LUT color grading
    tonemapping
    ue4 sequencer
    pbr -physical based rendering
    BRDF
    /sockjs-node/info 报错问题
  • 原文地址:https://www.cnblogs.com/yoyo1216/p/12794252.html
Copyright © 2011-2022 走看看