Home Java SCJP SCWCD Servlet Submit News Contact Us Site Map


Over 500 magazines for free (including Oracle Magazine)!

Yes all of them are FREE. You can subscribe to ALL of them.
Click here to apply today!

JavaDeveloper.co.in network has launched a dedicated site just for Java Examples. You can now learn java language by examples.

Please visit Java Examples to get started !

/*

Java SimpleDateFormat example.

This Java SimpleDateFormat example describes how class is defined and being used in Java language.

*/

import java.text.SimpleDateFormat;

import java.util.Date;

public class JavaSimpleDateFormatExample{

public static void main(String args[]){

// Create Date object.

Date date = new Date();

//Specify the desired date format

String DATE_FORMAT = "MM/dd/yyyy";

//Create object of SimpleDateFormat and pass the desired date format.

SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);

/*

Use format method of SimpleDateFormat class to format the date.

*/

System.out.println("Today is " + sdf.format(date) );

}

}

/*

OUTPUT of the above given Java SimpleDateFormat Example would be :

Today is 02/06/2005

*/

For more java examples please visit Java Examples

Home Java SCJP SCWCD Servlet Site map