Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TimeZone Issues!!

 
Karthick Dharani Vidhya
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
 
Karthick Dharani Vidhya
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • 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?
 
Collins Mbianda
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Karthick !!!

what your question ? Lol


What's your time zone?
 
Collins Mbianda
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • 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
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15279
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic