Author
Java date conversion confusion...
bob reilly
Ranch Hand
Joined: Jan 22, 2007
Posts: 44
posted Jul 02, 2010 14:25:45
0
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
Sheriff
Joined: Sep 28, 2004
Posts: 16695
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
Books: Java Threads, 3rd Edition , Jini in a Nutshell , and Java Gems (contributor)
vinay babu reddy
Greenhorn
Joined: May 25, 2010
Posts: 6
Hi,
There is no way to convert string object to date object in java , but the vice versa will possible.
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
bob, UseCodeTags the next time you post some code. I have added them this time.
[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
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.
subject: Java date conversion confusion...