I want to get a formatted Date in Java

前端 未结 5 1662
广开言路
广开言路 2021-01-24 23:48

I want to get a new Date object with a SimpleDateFormat applied to it. I would like to do something like:

SimpleDateFormat myFormat =         


        
5条回答
  •  南笙
    南笙 (楼主)
    2021-01-25 00:24

    I think what you are trying to achieve does not make sense.

    A Date object represents time. You can not format it. But, you can get it's string representation in certain format. Like with myFormat.format(today).

提交回复
热议问题