Java - Convert String to Date

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public java.util.Date stringToDate(String datestring) {
        DateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
        java.util.Date date=null;
        try {
            date = df.parse(datestring);
        } catch (ParseException ex) {
        return date;
To know more about working with strings in different date formats read the complete documentation for the SimpleDateFormat.

Popular posts from this blog

Store your 450GB data on an A4 size paper: THE RAINBOW TECHNOLOGY

Java XML getElementById returning null, fix using XPath

Software Development Models