0

Is there a way to convert the date object into String. For example,

Date date = ......... ;

date.toString shows something like Wed April 17 00:00:00.0 CEST 2016"

and I want to display as only April 17th, removing extra informations.

Sandra
  • 419
  • 7
  • 17
  • 2
    http://stackoverflow.com/questions/4011075/how-do-you-format-the-day-of-the-month-to-say-11th-21st-or-23rd-in-java – assylias Jul 25 '16 at 14:36
  • http://stackoverflow.com/documentation/java/164/date-class/633/converting-date-to-a-certain-string-format#t=201607251439489136276 – Abubakkar Jul 25 '16 at 14:40

1 Answers1

1

Use SimpleDateFormat:

String strDate = new SimpleDatFormat("MMM dd").format(date);

as for st/rd/th you will need to add it manually, e.g. by doing if and appending those to the strDate.

Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115