Android Timestamp Format formatDateTime(Timestamp value)

Here you can find the source of formatDateTime(Timestamp value)

Description

format Date Time

Declaration

public static String formatDateTime(Timestamp value) 

Method Source Code

import java.sql.Time;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.TimeZone;

public class Main{
    public final static String ISO_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
    public static String formatDateTime(Timestamp value) {
        return formatDateTime(value, ISO_DATETIME_FORMAT);
    }//w w w.j  a va2  s.  co  m
    public static String formatDateTime(Timestamp value,
            String defaultFormat) {
        if (value == null) {
            return "";
        }
        String strFormatStyle = StringUtils.isEmpty(defaultFormat) ? ISO_DATETIME_FORMAT
                : defaultFormat;
        SimpleDateFormat objSimpleDateFormat = new SimpleDateFormat(
                strFormatStyle);
        return objSimpleDateFormat.format(value);
    }
}

Related

  1. format(Timestamp tt, String pattern)
  2. formatDate(Timestamp value)
  3. formatDate(Timestamp value, String defaultFormat)
  4. formatDateTime(Timestamp value, String defaultFormat)
  5. formatShortDate(Timestamp value)
  6. formatShortDate(Timestamp value, String defaultFormat)
  7. timestampToISO8601(Timestamp aTimestamp)