Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

UTC to local time conversion is working in local code but not working at server

 
Greenhorn
Posts: 22
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi I am working on set top box (STB) application where we need to convert UTC time to local time and display it on App.
From some third party API's we are getting time in UTC as String and we need to convert it to local time zone and display it on App.
below is the code :


after checking server logs till dateFormateInLocalTimeZone its working fine but String formattedTime = displayTime.format(d); after this line of code
the formattedTime var contains the time in UTC and not in local
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the obvious difference is that for the SimpleDateFormatter that works, you called setTimeZone, whereas you didn't on the other...
 
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what you expect "local" time to be, but if you don't specify a timezone in a SimpleDateFormat object then the JVM's default timezone is used. This is normally the timezone configured into the computer where the code is running.

And that timezone is not necessarily the timezone of the location where the server is located. Have you checked what the default timezone is in your server?
 
Amruta nikam
Greenhorn
Posts: 22
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you guys after calling settimezone method it worked. I am working in EST time zone and server time is UTC
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic