Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Time conversion to IST from EST

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Sorry I have posted wrongly in SCEA Section

My database and app. servers are running in US. I need to display a time column in the JSP, both EST and IST time.

My trying to convert the EST time to IST like below
-------------------------------------------------------
String startDateString = "12/23/2005 11:20:00"; (EST)
java.util.Date olddate = new java.util.Date(startDateString);

java.text.SimpleDateFormat simple_date = new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss");

simple_date.setTimeZone(TimeZone.getTimeZone("Asia/Calcutta"));
java.util.Date newdate = new java.util.Date(simple_date.format(olddate));

java.text.DateFormat hrmins = new java.text.SimpleDateFormat("HH:mm");
String finalTime = hrmins.format(newdate);
log.info("Here in Home Meeting Time IST --> "+finalTime);

The result is - 11:20 (IST)

But for me it�s always displaying the same time for both EST and IST.

Is there anything wrong in the above code snippet? If so, please correct me.

Thanks and Regards,

Bala
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's probably my job that's being offshored here, but anyway...

Avoid the deprecated constructor Date(String): use DateFormat's parse instead:
 
There's a way to do it better - find it. -Edison. A better tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic