Java Utililty Methods Timestamp Format

List of utility methods to do Timestamp Format

Description

The list of methods to do Timestamp Format are organized into topic(s).

Method

Stringformat(final Date date)
format
String milliseconds = new SimpleDateFormat(FORMAT_PATTERN).format(date);
if (date instanceof Timestamp) {
    Timestamp timestamp = (Timestamp) date;
    final int nanos = timestamp.getNanos();
    int microseconds = nanos / 1000;
    milliseconds = milliseconds.substring(0, milliseconds.indexOf(".") + 1)
            + String.format("%06d", microseconds);
return milliseconds;
Stringformat(final long unixTimeStamp)
format
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
return sdf.format(new Date(unixTimeStamp * 1000L));
Stringformat(long timestamp)
format
SimpleDateFormat format = formats.poll();
if (format == null) {
    format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    format.setTimeZone(TimeZone.getTimeZone("GMT+8"));
try {
    return format.format(new Date(timestamp));
} finally {
...
Stringformat(long timeStamp)
Formats a numeric timestamp into a textual representation.
return FORMAT.format(new Date(timeStamp));
Timestampformat(Timestamp time)
format
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = sdf.format(time);
date = date.substring(0, 10) + " 00:00:00";
time = new Timestamp(sdf.parse(date).getTime());
return time;
Stringformat2AdwordsTimestamp(Date date)
format Adwords Timestamp
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.HOUR, -8);
return format("yyyyMMdd HHmmss", c.getTime()) + " UTC";
Stringformat8chars(long timestamp)
formatchars
return format8chars(new Date(timestamp));
StringformataDataHoraMinuto(Timestamp dataHora)
Formata a Data, a Hora e o Minuto
if (dataHora == null) {
    return "";
SimpleDateFormat formatador = new SimpleDateFormat("dd/MM/yyyy HH:mm");
return formatador.format(dataHora);
StringformatCalendar(Timestamp stamp)
format Calendar
SimpleDateFormat format = new SimpleDateFormat("MMM dd yyyy HH:mm:ss", new Locale("en", "US"));
return format.format(stamp) + " GMT";
StringformatCurrentDateTimeStamp(final String dateFormatString)
Supplies Current Date in the given dateFormat.
String tmpString = "";
SimpleDateFormat format = new SimpleDateFormat(dateFormatString);
tmpString = format.format(new Date());
return tmpString;