• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems with Calendar and SimpleDateFormat when using UTC time zone

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Setting Calendar time zone to UTC causes weird problems. Please see sample below:

This the output doesn't make sense to me at all.
In first sysout the time is correct. In second sysout using SimpleDateFormatter time is changed to 11.55 AM, that is just outright weird.
Int third sysout time goes to 17.55 PM, which is again unexpected. And finally using SImpleDateFormat again, it prints out expected time.

Any comments or explanations why this happens are warmly welcomed

My technical stats:
OS - Ubuntu 8.04
Java - 1.6.0_07
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


by the above statement ...the time field of the calculator object never gets changed......but infact the other fields with in the calculator gets initialized ...the otherfileds like dstSavings , useDaysavings etc....

to check this you can actually print the 'cal' object using print statement ...



or you can compare two object outputs....like below


if you run above...the time field would show same time (with few millisecond gap for comiler) for both the instaces like GMT and NZ-CHAT...but the other fileds of the object differ..



the above statement just gets the time field out of the cal object... with out any effect of timezone field..



in the above line time1 would be still same.....but when it formats it makes use of timezone to amend it and print the localized time....for the timezone mentioned
 
Innar Made
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you jittu gound for clearing that up!
 
Police line, do not cross. Well, this tiny ad can go through:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic