Here you can find the source of getDisplayDate(Date date, TimeZone tz, Locale inLocale, int style, boolean includeTime)
private static String getDisplayDate(Date date, TimeZone tz, Locale inLocale, int style, boolean includeTime)
//package com.java2s; import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; public class Main { /**//from w w w. ja v a 2 s . c o m * Private method for getting display date for a particular style: short, * medium, long or full. */ private static String getDisplayDate(Date date, TimeZone tz, Locale inLocale, int style, boolean includeTime) { if (date == null || inLocale == null) { return null; } // if not given a timezone but time is desired, default to GMT; // otherwise no default (SimpleDateFormat will revert to server timezone // in that case) if (includeTime && (tz == null)) { tz = TimeZone.getTimeZone("GMT"); } try { SimpleDateFormat formatter; if (includeTime) { formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(style, style, inLocale); } else { formatter = (SimpleDateFormat) DateFormat.getDateInstance(style, inLocale); } if (tz != null) { formatter.setTimeZone(tz); } return formatter.format(date); } catch (Exception e1) { // should never happen try { SimpleDateFormat formatter; if (includeTime) { formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(style, style, Locale.getDefault()); } else { formatter = (SimpleDateFormat) DateFormat.getDateInstance(style, Locale.getDefault()); } return formatter.format(date); } catch (Exception e2) { // should really never happen return date.toString(); } } } }