John Error John Error - 1 year ago 120
Android Question

Get day, month and year separately using SimpleDateFormat

I have a

like this

SimpleDateFormat format = new SimpleDateFormat("MMM dd,yyyy hh:mm");
String date = format.format(Date.parse(;

I'm giving date with the format like

Now, I want to get day, month and year separately. How can I implement this?

Answer Source

If you need to get the values separately, then use more than one SimpleDateFormat.

SimpleDateFormat dayFormat = new SimpleDateFormat("dd");
String day = dayFormat.format(Date.parse(;

SimpleDateFormat monthFormat = new SimpleDateFormat("MM");
String month = monthFormat .format(Date.parse(;


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download