Convert String to Date in Java

In this article, you will see how to convert string to date format in Java

package com.kruders.core;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ConvertStringToDate {
	public static void main( String[] args ) {
		String date = "11/22/2012";
		SimpleDateFormat sf= new SimpleDateFormat("MM/dd/yyyy");
		Date d;
		try {
			d = sf.parse(date);
		} catch (ParseException e) {

When you run the above example you’ll get an output like:

Thu Nov 22 00:00:00 IST 2012

No comments yet.

Leave a Reply