• 时间java


    新文章移至 
    http://cffile.sinaapp.com/?p=26
     

    一、当前时间

    1.
    Calendar now=Calendar.getInstance();
    String time=now.get(Calendar.YEAR)+"-"+(now.get(Calendar.MONTH)+1)+"-"+now.get(Calendar.DAY_OF_MONTH)+" "
        +now.get(Calendar.HOUR_OF_DAY)+":"+now.get(Calendar.MINUTE)+":"+now.get(Calendar.SECOND);


    2.
    24小时制
    SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd" + " " + "HH:mm:ss");
    String datetime = tempDate.format(new java.util.Date());
    12小时制
    SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd" + " " + "hh:mm:ss");
    String datetime = tempDate.format(new java.util.Date());

    二、程序运行时间

    long begin,end,time;
    Date mydate=new Date();
    begin=mydate.getTime();

    Date mydate2=new Date();
    end=mydate2.getTime();
    time=end-begin;

  • 相关阅读:
    MySQL
    MySQL -数据库备份
    MySQL
    MySQL
    MySQL
    MySQL
    MySQL
    MySQL
    MySQL
    53端口反弹shell
  • 原文地址:https://www.cnblogs.com/chenzhihong/p/1559080.html
Copyright © 2020-2023  润新知