Here you can find the source of timestampToString(java.sql.Timestamp a_Timestamp, String aS_Format)
Parameter | Description |
---|---|
a_Timestamp | Timestamp containing time |
aS_Format | String containing format specifications if format is null then format is "yyyy-MM-dd hh:mm:ss" |
public static String timestampToString(java.sql.Timestamp a_Timestamp, String aS_Format)
//package com.java2s; /*/*from w ww .java 2 s .c o m*/ NetForm Library --------------- Copyright (C) 2001-2005 - Sampsa Sohlman, Teemu Sohlman This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import java.text.SimpleDateFormat; public class Main { /** * Converts java.sql.Timestamp to String with using specified format * @param a_Timestamp Timestamp containing time * @param aS_Format String containing format specifications * if format is null then format is "yyyy-MM-dd hh:mm:ss" * @return String containing datetime * * @see java.text.SimpleDateFormat for format options */ public static String timestampToString(java.sql.Timestamp a_Timestamp, String aS_Format) { if (aS_Format == null) { aS_Format = "yyyy-MM-dd hh:mm:ss"; } if (a_Timestamp == null) return ""; SimpleDateFormat l_SimpleDateFormat = new SimpleDateFormat(aS_Format); return l_SimpleDateFormat.format(a_Timestamp); } }