开发者

How can I convert a String date with full month names to a Date object in java?

How can I convert dates with full month n开发者_如何学编程ames into a Date object in Java? Here's a sample date that I need to convert: 6 December 2002.

Thanks.


 String str = "6 December 2002";
 DateFormat formatter = new SimpleDateFormat("dd MMM yyyy");
 Date date = (Date)formatter.parse(str);
  • Here is working IDE One demo

Must See

  • API Doc


Have a look at SimpleDateFormat

SimpleDateFormat sdf = new SimpleDateFormat("d MMMMM yyyy", Locale.US);
Date d = sdf.parse("6 December 2002");
System.out.println(d);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜