2012-04-24 88 views
-4

可能重复:
Formatting Dates using a Format class (or otherwise if)如何转换 “2012-04-30” 的日期为 “04-APR-2012” 格式

我使用 “我的SQL” 分贝,在我的数据库表中,我将日期存储为“2012-04-30”格式,但现在我必须在此“2012年4月4日”格式的jsp页面中显示它。

我该如何使用Java代码?

+2

[解析](http://stackoverflow.com/questions/6953252/generic-way-to-parse-dates-in-java)和[格式化](http://stackoverflow.com/questions/6065507/formatting-dates-using-a-format-class-or-otherwise-if)日期在堆栈溢出时已被充分覆盖 – 2012-04-24 11:54:59

+0

是的,我做到了..谢谢 – 2012-04-24 11:58:05

回答

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); 
+0

谢谢,我做到了 – 2012-04-25 04:09:49