Here you can find the source of getDateFormat(java.util.Date date)
Parameter | Description |
---|---|
date | a java.util.Date or java.sql.Date |
public static String getDateFormat(java.util.Date date)
//package com.java2s; import java.text.SimpleDateFormat; public class Main { /** The date format string:(yyyy-MM-dd) */ public static final String DATE_FORMAT_STR = "yyyy-MM-dd"; /**//from w w w. j av a 2 s.c o m * getting a date string like 'yyyy-MM-dd' from a java.util.Date or java.sql.Date * * @param date a java.util.Date or java.sql.Date * @return a string like 'yyyy-MM-dd' */ public static String getDateFormat(java.util.Date date) { return getFormat(date, DATE_FORMAT_STR); } public static String getFormat(java.util.Date date, String parseFormat) { if (null == date) { return null; } if (null == parseFormat || "".equalsIgnoreCase(parseFormat)) { return date.toString(); } return new SimpleDateFormat(parseFormat).format(date); } }