Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java date conversion confusion...

 
bob reilly
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having an issue converting dates in Java. Here's my syntax:



Very frustrating. Any constructive comments / criticism is appreciated. Thanking you in advance...

 
Henry Wong
author
Marshal
Pie
Posts: 21126
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Date objects doesn't have a configurable format. If you just print it, you will get a preset format, as you have seen.

If you want a particular format, you will need to format() it to a string and print it -- as you have done earler in the example.

Henry

 
vinay babu reddy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

There is no way to convert string object to date object in java, but the vice versa will possible.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bob, UseCodeTags the next time you post some code. I have added them this time.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vinay babu reddy wrote:Hi,

There is no way to convert string object to date object in java, but the vice versa will possible.

You might have misunderstood the question. And yes, you can convert strings into dates. That's what dateFormat.parse is doing in the code above.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic