krnitish1803
krnitish1803

Reputation: 9

How to convert from one date format to another in Java?

My input is in the format of Sep 22, 2008 and how to convert it into 9/22/2008 using JAVA?

Upvotes: -7

Views: 845

Answers (1)

Prabhakaran Ramaswamy
Prabhakaran Ramaswamy

Reputation: 26094

Do like this

   Date date = new SimpleDateFormat("MMM d, yyyy").parse("Sep 22, 2008");
   String formattedDate = new SimpleDateFormat("MM/dd/yyyy").format(date);
   System.out.println(formattedDate);

output

09/22/2008

Upvotes: 2

Related Questions