Java SQL Date Get getDate(Timestamp ts)

Here you can find the source of getDate(Timestamp ts)

Description

get Date

License

Open Source License

Declaration

public static String getDate(Timestamp ts) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String getDate(Timestamp ts) {
        if (ts == null)
            return "";

        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String tsStr = sdf.format(ts);
        return tsStr;
    }/*www.ja va  2  s  .  c  om*/

    public static String getDate(Date ts) {
        if (ts == null)
            return "";

        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String tsStr = sdf.format(ts);
        return tsStr;
    }

    public static Date getDate(String dateString) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date;
        try {
            date = sdf.parse(dateString);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
        return date;
    }
}

Related

  1. getDate(String value)
  2. getDate(String year, String month, String day)
  3. getDate(Timestamp establishdate)
  4. getDate(Timestamp timestamp)
  5. getDate(Timestamp timestamp)
  6. getDateAddMonth(java.sql.Date date, int months)
  7. getDateAsLong(ResultSet rset, Enum field)
  8. getDateAsLong(Timestamp date)
  9. getDateBefore(Date date, Integer before)