Java SimpleDateFormat format time zone as "PST", "Pacific Standard Time", "-0800"

Description

Java SimpleDateFormat format time zone as "PST", "Pacific Standard Time", "-0800"

import java.text.SimpleDateFormat;
import java.util.Date;
 
public class Main {
 
  public static void main(String[] args) {
     Date date = new Date();
  
     SimpleDateFormat sdf = new SimpleDateFormat("zzz");
     System.out.println("TimeZone in z format : " + sdf.format(date));

     sdf = new SimpleDateFormat("zzzz");
     System.out.println("TimeZone in zzzz format : " + sdf.format(date));

     sdf = new SimpleDateFormat("Z");
     System.out.println("TimeZone in Z format : " + sdf.format(date));
  }//from w  ww. j  a  v  a  2 s .c  o  m
}



PreviousNext

Related