Convert String to Calendar
I'm trying to convert a String to Calendar. This is my attempt:
Code:
String content = "Thu Aug 05 21:07:55 CDT 2010";
SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
format.applyPattern(content); //line 65
...
//my attempt stopped here because of Exception.
I end up getting this exception:
Code:
java.lang.IllegalArgumentException: Illegal pattern character 'T'
at java.text.SimpleDateFormat.translatePattern(Unknown Source)
at java.text.SimpleDateFormat.applyLocalizedPattern(Unknown Source)
at sudoku.SudokuWorld.getTimeOfLastExecution(SudokuWorld.java:65)
at sudoku.SudokuWorld.<init>(SudokuWorld.java:28)
at sudoku.DriverProgram.main(DriverProgram.java:5)
The only 'T' in the String content is T in Thu. Consequently, I decided to do this:
Code:
SimpleDateFormat format1 = new SimpleDateFormat("EEE");
format1.applyPattern("Wed"); //line 63
and evidently enough, I get an exception:
Code:
java.lang.IllegalArgumentException: Illegal pattern character 'e'
at java.text.SimpleDateFormat.compile(Unknown Source)
at java.text.SimpleDateFormat.applyPattern(Unknown Source)
at sudoku.SudokuWorld.getTimeOfLastExecution(SudokuWorld.java:63)
at sudoku.SudokuWorld.<init>(SudokuWorld.java:28)
at sudoku.DriverProgram.main(DriverProgram.java:5)
Now when I do something like this:
Code:
SimpleDateFormat format1 = new SimpleDateFormat("mm/dd/yy");
format1.applyPattern("05/18/92");
I get no exception.
Anyone know what I'm doing wrong? Thanks in advance!