Format daty JAVA
Chcę sformatować2012-05-04 00:00:00.0
do04-MAY-2012
. wypróbowałem to z poniższymi krokami.
<code> SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd 'T' HH:mm:ss.SSS"); Date date; String dateformat = ""; try { date = sdf.parse("2012-05-04 00:00:00.0"); sdf.applyPattern("DD-MON-RR"); dateformat = sdf.format(date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code>
ale mam poniżej wyjątek.
<code>java.text.ParseException: Unparseable date: "2012-05-04 00:00:00.0" at java.text.DateFormat.parse(DateFormat.java:337) at com.am.test.Commit.main(Example.java:33)` </code>
Jak mogłem to zrobić?