Java Display Date In Different Formats

Chapter: Date and Time Last Updated: 03-09-2016 11:50:41 UTC

Program:

            /* ............... START ............... */
                
import java.text.*;
import java.util.*;

public class JavaDateInDifferentFormat {

	public static void main(String[] args) {
		Date dt = new Date(1000000000000L);

		DateFormat[] dtformat = new DateFormat[6];
		dtformat[0] = DateFormat.getInstance();
		dtformat[1] = DateFormat.getDateInstance();
		dtformat[2] = DateFormat.getDateInstance(DateFormat.MEDIUM);
		dtformat[3] = DateFormat.getDateInstance(DateFormat.FULL);
		dtformat[4] = DateFormat.getDateInstance(DateFormat.LONG);
		dtformat[5] = DateFormat.getDateInstance(DateFormat.SHORT);

		for (DateFormat dateform : dtformat)
			System.out.println(dateform.format(dt));
	}
}
                /* ............... END ............... */
        

Output

9/9/01 5:46 AM
Sep 9, 2001
Sep 9, 2001
Sunday, September 9, 2001
September 9, 2001
9/9/01

Tags

Display Date In Different Formats, Java, Date And Time, DateFormatSymbols

Similar Programs Chapter Last Updated
Java Format Time In 24 Hour Format Date and Time 25-10-2016
Java Month In MMM Format Date and Time 25-10-2016
Java Display Week Number Of The Year Date and Time 03-09-2016
Java Display Time In Italian Language Date and Time 02-09-2016
Java Display Time In Different Country's Format Date and Time 02-09-2016
Java Add Time To Date Example Date and Time 02-09-2016
Java Format Seconds Example Date and Time 02-09-2016
Java Date And Time Display Example Date and Time 02-09-2016
Java Display Hour And Minute Example Date and Time 01-09-2016
Java Displaying Month Name Example Date and Time 01-09-2016
Java Program To Format Date To yyyy/MM/dd Example Date and Time 30-06-2016
Java Program To Format Date To MM/dd/yyyy Example Date and Time 30-06-2016
Java Program To Format Date To dd/MM/yyyy Example Date and Time 30-06-2016
Weekdays In Java Example Date and Time 29-04-2016
Parse String Into Date In Java Date and Time 29-04-2016
Milliseconds To Date In Java Date and Time 29-04-2016
Gregorian Calendar In Java Date and Time 29-04-2016
Add Years To Date In Java Date and Time 29-04-2016
Add Month To Date In Java Date and Time 29-04-2016
Add Hours To Date In Java Date and Time 29-04-2016
SimpleDateFormat In Java Date and Time 28-04-2016
Date Format Using SimpleDateFormat In Java Date and Time 28-04-2016
Date In Java Example Date and Time 28-04-2016
AM PM Time Using SimpleDateFormat In Java Date and Time 28-04-2016
Time Zone In Java Example Date and Time 27-04-2016
Leap Years Between Date Range In Java Date and Time 27-04-2016
Java GMT Time Example Date and Time 27-04-2016
Epoch Time In Java Date and Time 27-04-2016
Day Of Year In Java Date and Time 27-04-2016
Day Of The Week In Java Date and Time 27-04-2016

1 2