aspose file tools*
The moose likes Beginning Java and the fly likes Issue with Date objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Issue with Date objects" Watch "Issue with Date objects" New topic
Author

Issue with Date objects

liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
Hi all, I have this simple method converting String dates to Dates to Strings of another format. For some reason the final result is one date for both Strings. I want to understand what's happening in the method that causes such behavior. Much appreciated.
Output:
start: 01/30/2012 -->January 30, 2012
end: 09/30/2012 -->January 30, 2012

Method:
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

liliya woland wrote:Hi all, I have this simple method converting String dates to Dates to Strings of another format. For some reason the final result is one date for both Strings. I want to understand what's happening in the method that causes such behavior. Much appreciated.
Output:
start: 01/30/2012 -->January 30, 2012
end: 09/30/2012 -->January 30, 2012

Method:



Note: m = minutes


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
Ok, now I'm seeing more of the issue. This convertion of 09/30/2012 -->January 30, 2012 is happening regardless of having or not having another date. Hm...
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11419
    
  16

to further emphasize Henry's point...

m is not the same thing as M.

Therefore, mm is not the same thing as MM.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
Got it, thanks a lot!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue with Date objects