Here you can find the source of formatDate(java.util.Date date)
String
Parameter | Description |
---|---|
date | JDBC format date |
public static String formatDate(java.util.Date date)
//package com.java2s; /*//from www .j av a 2 s .co m * @(#)ConversionUtils.java * * Copyright by ObjectFrontier, Inc., * 12225 Broadleaf Lane, Alpharetta, GA 30005, U.S.A. * All rights reserved. * * This software is the confidential and proprietary information * of ObjectFrontier, Inc. You shall not disclose such Confidential * Information and shall use it only in accordance with the terms of * the license agreement you entered into with ObjectFrontier. */ import java.sql.Timestamp; import java.text.SimpleDateFormat; public class Main { protected static SimpleDateFormat userDateFmt = new SimpleDateFormat("dd-MM-yyyy"); /** * This method converts a JDBC format date into a <code>String</code> * * @param date JDBC format date * * @return date in "dd-MMM-yyyy" format */ public static String formatDate(java.util.Date date) { if (date == null) return null; return userDateFmt.format(date); } /** * This method converts a JDBC format date into a <code>String</code> * * @param date JDBC format date * @param dateFormat * * @return date in user defined format */ public static String formatDate(java.util.Date date, String simpleDateFormat) { if (date == null) return null; return new SimpleDateFormat(simpleDateFormat).format(date); } /** * This method converts a JDBC format date into a <code>String</code> * * @param date JDBC format time * @param onlyTime controls whether date will be included or not * * @return date in "dd-MMM-yyyy" format */ public static String formatDate(Timestamp time) { if (time == null) return null; return userDateFmt.format(time); } }