How to get current timestamp in string format in Java? “yyyy.MM.dd.HH.mm.ss”

前端 未结 7 837
天涯浪人
天涯浪人 2020-12-04 06:27

How to get timestamp in string format in Java? \"yyyy.MM.dd.HH.mm.ss\"

String timeStamp = new SimpleDateFormat(\"yyyy.MM.dd.HH.mm.ss\").format(new Timestamp(         


        
相关标签:
7条回答
  • 2020-12-04 07:24

    Replace

    new Timestamp();
    

    with

    new java.util.Date()
    

    because there is no default constructor for Timestamp, or you can do it with the method:

    new Timestamp(System.currentTimeMillis());
    
    0 讨论(0)
提交回复
热议问题