Results 1 to 3 of 3

Thread: Date & time Conversion PST Pacific Standard Time to GMT

  1. #1
    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.

  2. #2
    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)

  3. #3
    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>

Similar Threads

  1. Replies: 2
    Last Post: 25-01-2012, 07:59 PM
  2. Replies: 7
    Last Post: 02-12-2011, 12:04 PM
  3. Replies: 2
    Last Post: 29-11-2011, 09:29 AM
  4. Replies: 8
    Last Post: 19-10-2011, 05:08 AM
  5. Date and Time control panel missing "Internet Time"
    By life036 in forum Windows Server Help
    Replies: 1
    Last Post: 30-01-2008, 06:19 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,719,561.28551 seconds with 17 queries