Here you can find the source of formatDate(Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String formatDate(Date date)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /** Field description */ public static final String DATE_PATTERN = "yyyy-MM-dd HH-mm-ss"; /**//from ww w.ja v a 2 s . c om * Method description * * * @param date * @param tz * * @return */ public static String formatDate(Date date, TimeZone tz) { SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN); if (tz != null) { sdf.setTimeZone(tz); } return sdf.format(date); } /** * Method description * * * @param date * * @return */ public static String formatDate(Date date) { return formatDate(date, null); } }