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

后端 未结 5 1032
再見小時候
再見小時候 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:07

    Seeing that you are using a dateformat in each method, you can use a different format string in each. For example:

    public long getTimeStampDay()
        {
    
                String day = new SimpleDateFormat("dd")
            .format(new Date(born_date.getDate())); 
             .....
    
                  return Long.parseLong(day); //just the day
    
        }
    

提交回复
热议问题