java get date marker field(am/pm)

后端 未结 5 1322
没有蜡笔的小新
没有蜡笔的小新 2021-01-12 04:07

I need to get the field AM/PM in date object. How can i get it?

This is my code.

String startTime =\"01:05 PM\";
 SimpleDateFormat sdf = new SimpleDa         


        
5条回答
  •  无人共我
    2021-01-12 04:50

    Calendar is probably best, but you could use DateFormat, too:

    String amPm = new SimpleDateFormat("aa").format(time);
    

    The TimeZone caveat also applies here.

提交回复
热议问题