How can I insert special characters in SimpleDateFormat?

前端 未结 1 1352
灰色年华
灰色年华 2020-12-16 09:27

I want to insert the word \'at\' in a SimpleDateFormat so a date would look like:

Wed, 26 May 2010 at 11:17am

I\'m

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-16 09:40

    You can escape literals using single quotes.

    SimpleDateFormat formatter = new SimpleDateFormat("EEE, d MMM yyyy 'at' hh:mma");
    

    This will output Wed, 26 May 2010 at 11:17am

    0 讨论(0)
提交回复
热议问题