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
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem in SimpleDateFormat" Watch "Problem in SimpleDateFormat" New topic

Problem in SimpleDateFormat

Saptarshi Chakraborty

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

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

Joined: Oct 27, 2005
Posts: 19905

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:

How To Ask Questions How To Answer Questions
Saptarshi Chakraborty

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

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

Refer this Example will help you

Java Best Practices
Linux Best Practices
Amortization Calculator

I agree. Here's the link:
subject: Problem in SimpleDateFormat