Here you can find the source of toDateText(Date date)
public static String toDateText(Date date)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /**//from w w w . j a v a 2 s .co m * Default date format */ public static final String DATE_FORMAT = "yyyy-MM-dd"; public static String toDateText(Date date) { return toDateText(date, DATE_FORMAT); } public static String toDateText(Date date, String pattern) { if (date == null || pattern == null) { return null; } DateFormat dateFormat = createDateFormat(pattern); return dateFormat.format(date); } private static DateFormat createDateFormat(String pattern) { return new SimpleDateFormat(pattern, Locale.SIMPLIFIED_CHINESE); } }