Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

TimeZone Format Example

This example shows how to format time zone using Format class. In this program we use a pattern of special characters to time format.

Ads

TimeZone Format Example

     

This example shows how to format time zone using Format class. In this program we use a pattern of special characters to time format.

Description of the code :

SimpleDateFormat() : SimpleDateFormat class use for formatting and parsing dates. It allows for formatting date into text , parsing text into date and normalization.

format() : This method used for format Date class object into date / time and appends the it into the StringBuffer.

SecondFormat.java


import java.text.*;
import java.util.*;

public class TimeZoneFormat {

  public static void main(String args[]) {

  String s;
  Format formatter;
  Date date = new Date();

  formatter = new SimpleDateFormat("z")// PST`
  s = formatter.format(date);
  System.out.println("PST Time zone format : " + s);

  formatter = new SimpleDateFormat("zzzz");  // Pacific Standard Time
  s = formatter.format(date);
  System.out.println("Pacific Standard Time Time zone format : " + s);

  formatter = new SimpleDateFormat("Z")// -0800
  s = formatter.format(date);
  System.out.println("Time zone format : " + s);
  }
}


Output


2002.01.29.08.36.33
Wed, 30 Jan 2002 08:44:02 +0530

Download code

Advertisements

Share on Google+Share on Google+

TimeZone Format Example

Posted on: October 13, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: TimeZone Format Example  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads