1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
import java.util.Date;
import java.text.SimpleDateFormat;
public class TestDate
{
public static void testParseDate(String sDate) {
try {
Date d = stringToDate(sDate);
System.out.println(d.toString());
} catch(Exception e) {
System.err.println("Exception :");
e.printStackTrace();
}
}
public static Date stringToDate(String sDate) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("EEEE MM MMMM");
return sdf.parse(sDate);
}
public static void main(String[] args) {
testParseDate("2009-09-01");
//testParseDate("2002/10-20"); // ParseException
//testParseDate(null); // NullPointerException
}
} |