File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Problem in parsing String into a particular Date format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem in parsing String into a particular Date format" Watch "Problem in parsing String into a particular Date format" New topic
Author

Problem in parsing String into a particular Date format

Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

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
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

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: 3018
    
  10
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: 19718
    
  20

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in parsing String into a particular Date format