• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

SimpleDateFormat returns inconsistent date

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sam Kumar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic