Below code shows how to convert String to Date in java. It converts String Object to java.util.Date
/****************************************************************************************
* Created on 10-2011Copyright(c) https://kodehelp.com All Rights Reserved.
****************************************************************************************/
package com.kodehelp.javautil;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by https://kodehelp.com Date: 10/5/11
*/
public class StringToDate {
public static void main(String[] args) {
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
try {
Date yesterday = df.parse("04/12/1981");
System.out.println("Yesterday = " + df.format(yesterday));
} catch (ParseException e) {
e.printStackTrace();
}
}
}