John Error John Error - 2 months ago 13x
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?


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