• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Problem in SimpleDateFormat  RSS feed

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 61766
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What pattern are you using? Does the pattern match the input String?
 
Sheriff
Posts: 21465
97
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Saptarshi Chakraborty
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes I want to convert a Date into a Date with a specific format.
 
Saptarshi Chakraborty
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Refer this Example will help you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!