Mridang Agarwalla
Mridang Agarwalla

Reputation: 44978

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 names into a Date object in Java? Here's a sample date that I need to convert: 6 December 2002.

Thanks.

Upvotes: 3

Views: 15133

Answers (2)

FrVaBe
FrVaBe

Reputation: 49341

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

Upvotes: 1

Jigar Joshi
Jigar Joshi

Reputation: 240900

 String str = "6 December 2002";
 DateFormat formatter = new SimpleDateFormat("dd MMM yyyy");
 Date date = (Date)formatter.parse(str);

Must See

Upvotes: 11

Related Questions