Here you can find the source of DateToString(Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String DateToString(Date date)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String DATE_PATTERN = "yyyy-MM-dd HH:mm"; /**/*w ww . j av a2 s . c o m*/ * Convert date to string , default pattern is yyyy-MM-dd * @param date * @return * @Create Sin@2012/2/22 */ public static String DateToString(Date date) { return DateToString(date, DATE_PATTERN); } /** * Convert date to string * @param date * @param pattern * @return * @Create Sin@2012/2/22 */ public static String DateToString(Date date, String pattern) { if (date == null) { return ""; } else { SimpleDateFormat df = new SimpleDateFormat(pattern); return df.format(date); } } }