• 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

TimeZone Issues!!

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
 
Karthick Dharani Vidhya
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Sorry the first entry came blank as I was hitting the tab it took the control to Add Reply Button!!!

I have a date object say the cuttent date and time by new Date() - this gives me date and time as our local system time zone say the time part is 15:25:50.

But i need to convert this time to US time or Some other country's time and display it. How would i do that?
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Karthick !!!

what your question ? Lol


What's your time zone?
 
Collins Mbianda
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok,
you were typing very fast. Your post arrive before my one.

I hope the give a look to the link.
If you want to use TimeZone, use Calendar instead of Date.

You can get an instance the apposite TimeZone with

Calendar.getInstance(Locale aLocale) or
Calendar.getInstance(TimeZone zone, Locale aLocale)

Hope it help
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note: You can click the button on your post to edit it, so that you don't need to add a reply to your own post.

Class Date does not know anything about timezones. You can use a SimpleDateFormat object to convert your Date object to a string that you can display, and you can tell the SimpleDateFormat in which timezone you want to see it. For example:

[ June 27, 2008: Message edited by: Jesper Young ]
 
Karthick Dharani Vidhya
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Thanks for the responses.

I tried setting the timezone to the calendar and calling gettime() on that. That was not working. But as you told when we set the timezone to the Formatter it worked!!!

Thanks.
reply
    Bookmark Topic Watch Topic
  • New Topic