How to get the number of milliseconds elapsed so far today

后端 未结 4 1028
眼角桃花
眼角桃花 2021-02-13 07:27

I want to get the current time and date in milliseconds. How can I get this?

I tried this:

Date date=new Date() ;  
System.out.println(\"Today is \" +dat         


        
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-13 08:08

    Use this code to get the current date and time

    DateFormat dateFormat = new SimpleDateFormat("dd:MM:yyyy HH:mm:ss");
            Calendar calendar=Calendar.getInstance();
            Date date=calendar.getTime();
            date.getHours();
            date.getMinutes();
            date.getMonth();
            date.getSeconds();
            date.getYear();
    

提交回复
热议问题