• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Timezone conversion

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have this program



Here i am getting a time with a timezone and the timezone is in UTC, is that a correct assumption
the output is as follows, why is not as per the input
2013-10-15T12:43 -0600
1381862580000
2013-10-15T12:43 -0600


 
Master Rancher
Posts: 4197
57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jacob Sonia wrote:Here i am getting a time with a timezone and the timezone is in UTC, is that a correct assumption


I'm not sure what you mean, but I would say no, nothing there is in UTC. Except the strings -0600 and -0700 both reference timezones relative to UTC, if that's what you mean.
the output is as follows, why is not as per the input

Jacob Sonia wrote:2013-10-15T12:43 -0600
1381862580000
2013-10-15T12:43 -0600


You mean, why does it not use UTC-0700? Because you've requested that outFormat format the output using America/Denver, which currently gives Mountain Daylight Time, which is UTC-0600. If you want it to use a different time zone, identify the time zone you want to use, and tell the formatter to use that time zone.

Note that there is no difference in value between the date you call "date" and the one you call "mstTime". They represent exactly the same thing. Neither one has a time zone associated with it - Date objects never do. (Except when toString() is called on them, and the system default time zone is used.)

Try this:
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic