Here you can find the source of convertDateToString(Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String convertDateToString(Date date)
//package com.java2s; // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt import java.text.FieldPosition; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String TALEND_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss"; /**//from w w w. j av a 2s . c o m * Converts the given date to the specified string pattern "yyyy-MM-dd HH:mm:ss"; * * @param date * @return */ public static String convertDateToString(Date date) { String result = convertDateToString(date, TALEND_DATE_PATTERN); return result; } public static String convertDateToString(Date date, String pattern) { StringBuffer result = new StringBuffer(); SimpleDateFormat sdf = new SimpleDateFormat(pattern); sdf.format(date, result, new FieldPosition(0)); return result.toString(); } }