Java SQL Date Convert dateToString(Date date, String format)

Here you can find the source of dateToString(Date date, String format)

Description

Description:Change the java.sql.Timestamp format to java.util.String format

License

Open Source License

Parameter

Parameter Description

Return

String

Declaration

public static String dateToString(Date date, String format) 

Method Source Code

//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 "";
        }
    }
}

Related

  1. dateToSQLDate(java.util.Date d)
  2. dateToStamp(String date)
  3. dateToSTR(Date data, String formato)
  4. dateToStr(java.util.Date date)
  5. dateToString(Date date)
  6. dateToString(java.sql.Date d)
  7. dateToString(java.sql.Date data)
  8. dateToString(java.sql.Date datee)
  9. dateToString(java.util.Date date, String dateFmt)