Parse string to get Date
Date parse(String source)
- Parses text from the beginning of the given string to produce a date.
Object parseObject(String source, ParsePosition pos)
- Parses text from a string to produce a Date.
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
public class Main{
public static void main(String args[]) {
Date d = null;
try {
d = DateFormat.getDateInstance().parse("18-Nov-2010");
} catch (ParseException e) {
e.printStackTrace();
}
System.out.println(d);
}
}
The output:
Thu Nov 18 00:00:00 PST 2010