extract day from Date

后端 未结 3 2112
忘了有多久
忘了有多久 2021-02-02 12:15

I receive a timestamp from a SOAP service in milliseconds. So I do this:

Date date = new Date( mar.getEventDate() );

How can I extract the day

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-02 12:38

    Use Calendar for this:

    Calendar cal = Calendar.getInstance();
    cal.setTime(mar.getEventDate());
    int day = cal.get(Calendar.DAY_OF_MONTH);
    

提交回复
热议问题