-4

Possible Duplicate:
Formatting Dates using a Format class (or otherwise if )

I am using "My Sql" Db, In my DB table,i am storing Date in "2012-04-30" format but now i have to show it in my jsp page in this "04-Apr-2012" format.

How can i do it with Java Code?

Community
  • 1
  • 1
Dan
  • 2,086
  • 11
  • 71
  • 137
  • 2
    [Parsing](http://stackoverflow.com/questions/6953252/generic-way-to-parse-dates-in-java) and [Formatting](http://stackoverflow.com/questions/6065507/formatting-dates-using-a-format-class-or-otherwise-if) of dates is covered sufficiently on Stack Overflow – Lukas Eder Apr 24 '12 at 11:54

1 Answers1

1
    Date d = (new SimpleDateFormat("yyyy-MM-dd").parse("2012-04-30"));
    String result = (new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH).format(d));
    System.out.println(result);
Davide Consonni
  • 2,094
  • 26
  • 27