• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

how to format the date from GMT timezone to EST timezone?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to format the date from GMT ( DB column's data type is time stamp) to EST timezone but i am not able to do it..
I tried lot of things but still i couldn't succeed.

some piece of code i am pasting--





Please help me.. Thanks in advance..
 
Marshal
Posts: 79973
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What sort of format is AppConstants.Common.EST_DATE_FORMAT?

Why are you using EST to read the format if you want to convert it from GMT? Shouldn't you use a GMT type format there?
If you are reading a timestamp from a database, why do you need to convert it to a Date or Calendar object at all? Doesn't the database return a Timestamp object?
 
Campbell Ritchie
Marshal
Posts: 79973
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
... and welcome to the Ranch
 
arpit maurya
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:What sort of format is AppConstants.Common.EST_DATE_FORMAT?

Why are you using EST to read the format if you want to convert it from GMT? Shouldn't you use a GMT type format there?
If you are reading a timestamp from a database, why do you need to convert it to a Date or Calendar object at all? Doesn't the database return a Timestamp object?



AppConstants.Common.EST_DATE_FORMAT is nothing but the "yyyy-MM-dd HH:mm:ss a" format i am specifying in some CONSTANT file .
I don't know how to solve it so Can you please modify my code & send it..
Thank you so much..
 
arpit maurya
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:... and welcome to the Ranch




Thank you so much...
 
Campbell Ritchie
Marshal
Posts: 79973
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you would have a String in this format?
2011-07-29 03:54:21 pm
 
arpit maurya
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:So you would have a String in this format?
2011-07-29 03:54:21 pm

yes..
 
Campbell Ritchie
Marshal
Posts: 79973
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know any more. Sorry.

Anybody else?
 
Sheriff
Posts: 28329
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't convert a date from timezone A to timezone B, because a date doesn't have a timezone in the first place. So the question is meaningless.

You can certainly format a date to appear in timezone B, though. You already know how to do that: use a SimpleDateFormat, set its timezone to B, and use it to format the date. So just do that part.
 
arpit maurya
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:You can't convert a date from timezone A to timezone B, because a date doesn't have a timezone in the first place. So the question is meaningless.

You can certainly format a date to appear in timezone B, though. You already know how to do that: use a SimpleDateFormat, set its timezone to B, and use it to format the date. So just do that part.

yes It was my mistake actually, what i need is formatted date only.. after googling i found lots of answers but still i am not able to fix it..
Can you please let me know what could be the possible solution after seeing my code..
 
Paul Clapham
Sheriff
Posts: 28329
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure, I could give it a try. Post your code.
 
arpit maurya
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Sure, I could give it a try. Post your code.


 
Yeah, but is it art? What do you think tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic