Need to get current timestamp in Java

后端 未结 10 1748
南旧
南旧 2020-12-25 09:47

I need to get the current timestamp in Java, with the format of MM/DD/YYYY h:mm:ss AM/PM,

For example: 06/01/2000 10:01:50 AM

I ne

10条回答
  •  眼角桃花
    2020-12-25 10:29

    Try this single line solution :

    import java.util.Date;
    String timestamp = 
        new java.text.SimpleDateFormat("MM/dd/yyyy h:mm:ss a").format(new Date());
    

提交回复
热议问题