Hello,
is there a way to parse a formatted date like '01Feb06' using SimpleDateFormat?
"ddMMMyy" -> no
"dd''MMM''yy" -> no
???
TIA
Hi Denzel. This is actually quite straightforward using
SimpleDateFormat. You just need to make sure you use
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class Test {
public static void main(String[] args) throws ParseException {
// set up a test string
String testDate = "02Nov06";
// create SimpleDateFormat object based on test string
SimpleDateFormat format = new SimpleDateFormat("ddMMMyy");
// display the parsed results.
System.out.println("\"" + testDate + "\" parses to \"" +
format.parse(testDate) + "\"");
}
}
OUTPUT:
"02Nov06" parses to "Thu Nov 02 00:00:00 PST 2006"
Process finished with exit code 0