• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Problem in Changing Timezone (URGENT)

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have a small problem while changing timezone,
i have a calendar class which is in EST format,that i need
to change in PST , here iam not able to change the time,
while printing timezone value it is printing as correbt but it is
not showing the difference time,
Code:
SimpleDateFormat dateFormatori = new SimpleDateFormat(DATE_FORMAT);
dateFormatori.setTimeZone(TimeZone.getTimeZone("PST"));
Date d=new Date();
String formated_date=dateFormatori.format(d);
System.out.println(formated_date);
can you please help me how to resolve this issue..

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

Please post the complete code for the function and also the output.

Suraj
 
Naresh Talluri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
--------------------------
Please post the complete code for the function and also the output.
-----------------------------
Here is the code

Here i got in the date as in PST format but that is in String format ,
to make it as Date object i parsed using parse(), but iam getting the
current IST(Indian Standard Time) , i need it in a PST format can you
please help me out,

Thanks
-Naresh
[ March 12, 2008: Message edited by: Jim Yingst ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the future please use code tags. I have added them to your post above for readability.

Your problem is here:

This is equivalent to:

Unfortunately toString() will always use your computer's local time zone. If you want any timezone other than that, you can't use Date's toString() method. Instead use a DateFormat such as the one you've already created:

[ March 12, 2008: Message edited by: Jim Yingst ]
 
Rancher
Posts: 280
VI Editor C++ Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jim Yingst:
(...)
Your problem is here:

This is equivalent to:

Unfortunately toString() will always use your computer's local time zone.
(...)[ March 12, 2008: Message edited by: Jim Yingst ]



Nice catch!
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic