Minutes Format Example

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

Ads

Minutes Format Example

     

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

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

public class MinutesFormat {

  public static void main(String args[]) {

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

  formatter = new SimpleDateFormat("m")// 7
  s = formatter.format(date);
  System.out.println("The minutes : " + s);

  formatter = new SimpleDateFormat("mm");  // 07
  s = formatter.format(date);
  System.out.println("The minutes : " + s);
  }
}

Output:

The minutes : 9
The minutes : 09

Download code

Advertisements

Share on Google+Share on Google+

Minutes 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

Ads
 

Discuss: Minutes Format Example   View All Comments

Post your Comment


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

Ads

 

Ads