| Author |
Problem in parsing String into a particular Date format
|
Mohamed Sanaulla
Bartender
Joined: Sep 08, 2007
Posts: 2927
|
|
Hi,
I tried formatting a string into a particular Date format specified using the SimpleDateFormat class. But i wasn't successful in doing it. Below is the code which tried parsing the String
I get the following error message:
What might me the problem?
|
Mohamed Sanaulla | My Blog
|
 |
Balu Sadhasivam
Ranch Hand
Joined: Jan 01, 2009
Posts: 874
|
|
String str="2009-02-09T16:40:07Z";
Z reperesents TIMEZONE , the String did not match It has to represent TIMEZONE and not 'Z'. try like
String str="2009-02-09T16:40:07GMT";
Refer API
|
 |
Mohamed Sanaulla
Bartender
Joined: Sep 08, 2007
Posts: 2927
|
|
|
Thanks a lot. I had been stuck with it for a long time.
|
 |
Balu Sadhasivam
Ranch Hand
Joined: Jan 01, 2009
Posts: 874
|
|
You are welcome. and When you have stuck the best one can do is help himself rather than to wait for a thrid eye
Refer the API link to understand better
|
 |
Mike Simmons
Ranch Hand
Joined: Mar 05, 2008
Posts: 2778
|
|
Alternately, if your input string is supposed to end in Z (for Zulu time), you can tell the SimpleDateFormat to expect a literal 'Z' using single quotes, much like the literal 'T' it expects earlier:
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Balu Sadhasivam wrote:
You are welcome. and When you have stuck the best one can do is help himself rather than to wait for a thrid eye 
Actually, just asking someone to help you look for the problem helps a lot. I can't even count the number of times I had a problem, asked somebody to help me look for it, and then found it while the other person was still looking over my shoulder. The presence of the other person alone can sometimes work miracles.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: Problem in parsing String into a particular Date format
|
|
|