aspose file tools*
The moose likes Beginning Java and the fly likes Java date conversion confusion... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java date conversion confusion..." Watch "Java date conversion confusion..." New topic
Author

Java date conversion confusion...

bob reilly
Ranch Hand

Joined: Jan 22, 2007
Posts: 44
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: 18981
    
  40


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: 14688
    
  16

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: 14688
    
  16

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java date conversion confusion...