Here you can find the source of dateToString(Date date, String format)
Description:Change the java.sql.Timestamp format to java.util.String format
Parameter | Description |
---|
public static String dateToString(Date date, String format)
//package com.java2s; /*//from w w w.j av a 2s. c o m * $RCSfile: DatetimeUtil,v $$ * $Revision: 1.0 $ * $Date: 2011 $ * * Copyright (C) 2011 GyTech, Inc. All rights reserved. * * This software is the proprietary information of GyTech, Inc. * Use is subject to license terms. */ import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * <p>Description:Change the java.sql.Timestamp format to java.util.String format</p> * @param java.sql.Timestamp * @return String */ public static String dateToString(Date date, String format) { try { SimpleDateFormat myFormatter = new SimpleDateFormat(format); return myFormatter.format(date); } catch (Exception err) { return ""; } } }