Java Timestamp to String timestamptoStr(Timestamp time)

Here you can find the source of timestamptoStr(Timestamp time)

Description

timestampto Str

License

Apache License

Declaration

public static String timestamptoStr(Timestamp time) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final SimpleDateFormat yyyy_MM_dd = new SimpleDateFormat("yyyy-MM-dd");

    public static String timestamptoStr(Timestamp time) {
        // Date date = null;
        // if (null != time) {
        // date = new Date(time.getTime());
        // }/*from w w  w . j a v a2s . co  m*/
        return date2Str(yyyy_MM_dd);
    }

    public static String date2Str(SimpleDateFormat date_sdf) {
        Date date = getDate();
        if (null == date) {
            return null;
        }
        return date_sdf.format(date);
    }

    public static String date2Str(Date date, SimpleDateFormat date_sdf) {
        if (null == date) {
            return null;
        }
        return date_sdf.format(date);
    }

    public static Date getDate() {
        return new Date();
    }

    public static Date getDate(long millis) {
        return new Date(millis);
    }

    public static String getDate(String format) {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
}

Related

  1. timestamp2Str(Timestamp time, String format)
  2. timestamp2String(final java.sql.Timestamp value)
  3. timestamp2String(Timestamp timestamp, String pattern)
  4. timeStampToString(final Timestamp timestamp, final String format)
  5. timestampToString(java.sql.Timestamp a_Timestamp, String aS_Format)
  6. timestampToString(long timestamp)
  7. timestampToString(long timestamp)