how to retrieve day month and year from Timestamp(long format)

后端 未结 5 1035
再見小時候
再見小時候 2020-12-15 17:38

I need to retrieve day year and month from a timestamp object as long numbers:

public long getTimeStampDay()
    {

            String iDate = new SimpleDate         


        
5条回答
  •  鱼传尺愫
    2020-12-15 18:24

    long timestamp = bornDate.getTime();
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(timestamp);
    return cal.get(Calendar.YEAR);
    

    There are calendar fields for each property you need.

    Alternatively you can use joda-time:

    DateTime dateTime = new DateTime(bornDate.getDate());
    return datetime.getYear();
    

提交回复
热议问题