File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes SimpleDateFormat returns inconsistent date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "SimpleDateFormat returns inconsistent date" Watch "SimpleDateFormat returns inconsistent date" New topic
Author

SimpleDateFormat returns inconsistent date

Sam Kumar
Ranch Hand

Joined: Nov 30, 2001
Posts: 38
Hi,
I am seeing very strange problem with SimpleDateFormat, sometime I am seeing
four digit month instead of two between clone. For example first clone (JVM) will
return two digit month "01" and another clone (same code) return four digit
month "0001".
Here is the code snippet:
private static String customTimestamp;
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss z");
.....
if (customTimestamp == null)
customTimestamp = formatter.format(new java.util.Date());
We are using JDK 1.3.1, WAS 4 AE, AIX
Any thoughts why i am getting different month length.
Thanks.
SK
Chinmay Bajikar
Ranch Hand

Joined: Dec 08, 2001
Posts: 159
hi sushil,
I tried ur code on my machine.
But im gettin consistant results.(4 digit year)
Also what do u mean by JVM clone???
I have run the code on my Win Nt machine on JDK 1.4.
Thanks,
Chinmay


The strength of the Wolf is the pack & the strength of the pack is the wolf....Rudyard Kipling
Sam Kumar
Ranch Hand

Joined: Nov 30, 2001
Posts: 38
Hi Chinmay:
Thanks for your reply.
We are using WebSphere Application Server and for scalability reasons we created cloned AppServer i.e. multiple JVMs are running the same web application.
I am seeing 4 digit month instead of two. For example: For Jan, first JVM shows "01" and 2nd JVM may show "0001". All other informaiton is correct based on format specified in SimpleDateFormat.
Also this problem is not consistent, I saw only twice.
I am using JDK 1.3.1 running on AIX (unix).
Thanks.
Sushil
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SimpleDateFormat returns inconsistent date