• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to calculate time of different countries  RSS feed

 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,

I am looking for a way to fetch time of different countries.
I am in India.I need to fetch the china current time.
I tried below code but in output i get my local time only.

How do i correct it to get china local time?
Thanks.
[ August 04, 2008: Message edited by: Vishal Pandya ]
 
Kuladip Yadav
Ranch Hand
Posts: 162
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may Check this

For china UTC/GMT +8 hours
So fallowing code may help you

 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i created an instance using the code pasted by me above, i got local time
But when i printed the calendar object by calendar.toString() method i got proper timings. Is this strange?

Actually, i want to start a scheduler at 00:00:00 AM china time and my application may run in India/US.I tried the following.

Is there any better way exists?
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Date.toString() always formats its date using the default timezone. You can use DateFormat to use different timezones:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!