aspose file tools*
The moose likes Java in General and the fly likes Problem in SimpleDateFormat 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 » Java in General
Bookmark "Problem in SimpleDateFormat" Watch "Problem in SimpleDateFormat" New topic
Author

Problem in SimpleDateFormat

Saptarshi Chakraborty
Greenhorn

Joined: Jul 26, 2007
Posts: 23
hi folks ,
I am having a problem in SimpleDateFormat class. I have a method like this



running the code throws an exception like


Unparseable date: "Tue May 05 13:38:42 IST 2009"
at java.text.DateFormat.parse(Unknown Source)


Can any one figure out what is the problem here in this code?
and how can I convert the date to my desired format.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
What pattern are you using? Does the pattern match the input String?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Just what are you trying to do? Convert a Date into a Date? Why not just return the original Date object?

I think, given the method name, this is what you want:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Saptarshi Chakraborty
Greenhorn

Joined: Jul 26, 2007
Posts: 23
yes I want to convert a Date into a Date with a specific format.
Saptarshi Chakraborty
Greenhorn

Joined: Jul 26, 2007
Posts: 23
I was wrong in my approach.Date objects don't have a format.A date is the number of milliseconds since Jan 1st, 1970 UTC. It is a number. It has no format. SimpleDateFormat can parse it to a String with our desired format.
Vinoth Thirunavukarasu
Ranch Hand

Joined: Dec 18, 2008
Posts: 164

Hi,
Refer this Example will help you


Java Best Practices
Linux Best Practices
Amortization Calculator

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in SimpleDateFormat