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

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.

Ads

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

Share on Google+Share on Google+

Time Format Example

Posted on: April 17, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Time Format Example  

Post your Comment


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

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

Ads

 

Ads