Need to get current timestamp in Java

后端 未结 10 1763
南旧
南旧 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:27

    I did it like this when I wanted a tmiestamp

        String timeStamp = new SimpleDateFormat("yyyyMMddHHmmss").format(Calendar.getInstance().getTime());
    

    Hope it helps :) As a newbie I think it's self-explanatory

    I think you also need import java.text.SimpleDateFormat; header for it to work :))

提交回复
热议问题