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

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();

A little refreshment of this well-accepted thread that is a bit outdated by now.

Back in the day, Java 8 introduced Date and Time API which makes extracting much cleaner.

Let's assume that bornDate is instance of LocalDateTime.

bornDate.getDayOfMonth(); // extracts day of month
bornDate.getMonth();      // extracts month
bornDate.getYear();       // extracts year

Oracle reference: Java SE 8 Date and Time

Tags:

Datetime

Java