| 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: 32704
|
|
|
What pattern are you using? Does the pattern match the input String?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
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
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
|
 |
 |
|
|
subject: Problem in SimpleDateFormat
|
|
|