Here you can find the source of convertDateToStr(Date date, String format)
Parameter | Description |
---|---|
date | a parameter |
format | a parameter |
public static String convertDateToStr(Date date, String format)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss"; /**/*w w w. j a va2 s . c o m*/ * Date convert to String <br> * ------------------------------<br> * * @param date * @param format * @return */ public static String convertDateToStr(Date date, String format) { SimpleDateFormat f = new SimpleDateFormat(format, Locale.SIMPLIFIED_CHINESE); return f.format(date); } /** * Date convert to String (yyyy-MM-dd HH:mm:ss) <br> * ------------------------------<br> * * @param date * @return */ public static String convertDateToStr(Date date) { return convertDateToStr(date, DEFAULT_DATE_PATTERN); } }