Java DateFormat class has predefined format styles.
The DateFormat class defines five styles as constants:
import java.text.DateFormat; import java.util.Date; import java.util.Locale; public class Main { public static void main(String[] args) { Date today = new Date(); Locale defaultLocale = Locale.getDefault(); printDate(defaultLocale, today);//w w w . j ava2 s . c o m } public static void printDate(Locale locale, Date date) { DateFormat formatter; String formattedDate; // Format and print the date in SHORT style formatter = DateFormat.getDateInstance(DateFormat.SHORT, locale); formattedDate = formatter.format(date); System.out.println("SHORT: " + formattedDate); // Format and print the date in MEDIUM style formatter = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); formattedDate = formatter.format(date); System.out.println("MEDIUM: " + formattedDate); formatter = DateFormat.getDateInstance(DateFormat.LONG, locale); formattedDate = formatter.format(date); System.out.println("LONG: " + formattedDate); } }