The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

RE: Date formatting

Posted by Kishori Sharan on September 08, 2000 at 12:55 PM

Hi

I have written a short program to illustrate the date formatting. It may help you.

Thanx
Kishori
///////////////////Test.java
import java.util.* ;
import java.text.* ;

class Test {

public static void main(String[] args) {

// Get the curent date
Date dt = new Date () ;

// Set the date format as mm/dd/yyyy to display 09/08/2000
SimpleDateFormat df = new SimpleDateFormat ( "MM/dd/yyyy" );
System.out.println( df.format ( dt ) );

// Set the date format as d MMM yyyy to display o8 Sep 2000
//df = new SimpleDateFormat ( "d MMM yyyy" );
df.applyPattern ( "d MMM yyyy" ) ;
System.out.println( df.format ( dt ) );
}

}



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us