Java Timestamp Convert To convertTimestampToString(Timestamp str)

Here you can find the source of convertTimestampToString(Timestamp str)

Description

convert Timestamp To String

License

Apache License

Declaration

public static String convertTimestampToString(Timestamp str) 

Method Source Code

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

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

import java.text.SimpleDateFormat;

public class Main {
    public static String convertTimestampToString(Timestamp str) {
        return convertTimestampToString(str, "yyyy-MM-dd HH:mm:ss");
    }//from ww  w .  j av a 2  s .  c  o m

    public static String convertTimestampToString(Timestamp str,
            String format) {
        //Timestamp ts = new Timestamp(System.currentTimeMillis());
        String tsStr = "";
        DateFormat sdf = new SimpleDateFormat(format);
        tsStr = sdf.format(str);
        //System.out.println(tsStr);
        return tsStr;
    }
}

Related

  1. ConvertTimestamp(long sec)
  2. convertTimestamp(Timestamp timestamp)
  3. convertTimestampToDate(Timestamp timestamp)
  4. convertTimestampToDDMMMMYYYY(Timestamp dateTime)
  5. convertTimestampToString(Timestamp dateTime, String dateFormat)
  6. convertTimestampToStringWithoutTime(final Timestamp ts)
  7. convertToDate(Timestamp aTimeStamp)
  8. convertToDate(Timestamp timestamp)
  9. convertToEpochMillis(java.sql.Timestamp ts)