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

前端 未结 7 846
天涯浪人
天涯浪人 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:07

    Use java.util.Date class instead of Timestamp.

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

    This will get you the current date in the format specified.

提交回复
热议问题