Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 30-07-2009
Member
 
Join Date: Apr 2008
Posts: 19
Date & time Conversion PST Pacific Standard Time to GMT

Hello friends,

What is the best way to work with time zones? Is there any way to convert PST Pacific Standard Time (DateTime) to GMT?
If someone could help me? Can anyone show me the logic or a code snippet?

Thanks in advance.
Reply With Quote
  #2  
Old 30-07-2009
Member
 
Join Date: Apr 2008
Posts: 21
Re: Date & time Conversion PST Pacific Standard Time to GMT

There is difference of 8 hrs between both of them.
Pacific Standard Time (PST) is 8hrs behind Greenwich Mean Time (GMT)
Reply With Quote
  #3  
Old 30-07-2009
Member
 
Join Date: May 2008
Posts: 22
Re: Date & time Conversion PST Pacific Standard Time to GMT

Convert GMT to PST

This example helps you in converting a GMT time to PST time on the console. The SimpleDateFormat() constructor uses the given pattern and date format symbols. Here we use the date format as gmtFormat which gets converted to pstFormat. Then we have used getTimeZone() method to get the time of both the zones to be converted.

Pacific Standard Time (PST) = GMT-8

Pacific Daylight Time (PDT) = GMT-7

code

Code:
import java.util.*;
import java.text.*;
import java.io.*;

public class GMTtoPST{
  public static void main(String args[]){
    Date date = new Date();
      DateFormat pstFormat = new SimpleDateFormat();
      DateFormat gmtFormat = new SimpleDateFormat();
      TimeZone gmtTime = TimeZone.getTimeZone("GMT");
      TimeZone pstTime = TimeZone.getTimeZone("PST");
      
    pstFormat.setTimeZone(gmtTime);
      gmtFormat.setTimeZone(pstTime);
      System.out.println("GMT Time: " + pstFormat.format(date));
      System.out.println("PST Time: " + gmtFormat.format(date));
  }
}
Output

Code:
C:\unique>javac GMTtoPST.java

C:\unique>java GMTtoPST
GMT Time: 8/4/07 9:54 AM
PST Time: 8/4/07 2:54 AM

C:\unique>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Date & time Conversion PST Pacific Standard Time to GMT"
Thread Thread Starter Forum Replies Last Post
How to convert the Standard Time to Military Time in Microsoft Excel Anita Bath MS Office Support 2 25-01-2012 07:59 PM
?Time of Fury ?compare with ?Storm over the Pacific? Jasseen Video Games 7 02-12-2011 12:04 PM
error message: cant login This computer date/time is not synchornize with the date/time of network fazalhassan Networking & Security 2 29-11-2011 09:29 AM
Date and Time widget does not keep time correctly in Motorola Defy Sanat Portable Devices 8 19-10-2011 05:08 AM
Date and Time control panel missing "Internet Time" life036 Windows Server Help 1 30-01-2008 06:19 PM


All times are GMT +5.5. The time now is 10:09 PM.