Home Java Javadate Time Format Example
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Time Format Example

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

Time Format Example

     

This example shows how to format time 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.

FormattingTime.java
importjava.text.*;
importjava.util.*;

publicclassFormattingTime{

publicstaticvoidmain(Stringargs[]){
Locale[]locales={Locale.FRANCE,Locale.ITALY,Locale.CHINA};

Datedate=newDate();
Strings;

for(inti=0;i


Output

Date formate in French
Short  : 15:55
Medium  : 15:55:00
Long  : 15:55:00 IST
Full  : samedi 11 octobre 2008
Default  : 15:55:00

Date formate in Italian
Short  : 15.55
Medium  : 15.55.00
Long  : 15.55.00 IST
Full  : sabato 11 ottobre 2008
Default  : 15.55.00

Date formate in Chinese
Short  : ???3:55
Medium  : 15:55:00
Long  : ???03?55??00?
Full  : 2008年10??11? ?????
Default  : 15:55:00

Download code
Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 17, 2011

Ask Questions?    Discuss: Time Format Example  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Jera
December 13, 2011
wpVrNzcCOqiKrgO

I like to party, not look aritlces up online. You made it happen.
DMCA.com