Java Timestamp Format formatTimeToString(long timestamp)

Here you can find the source of formatTimeToString(long timestamp)

Description

format Time To String

License

Apache License

Declaration

public static String formatTimeToString(long timestamp) 

Method Source Code


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

import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class Main {
    private static final String ES_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
    private static final ThreadLocal<DateFormat> timef = new ThreadLocal<>();

    public static String formatTimeToString(long timestamp) {
        DateFormat sdf = timef.get();
        if (sdf == null) {
            sdf = new SimpleDateFormat(ES_DATE_FORMAT);
            timef.set(sdf);/*from w ww  .j  av  a 2  s  .  c  om*/
        }
        return sdf.format(timestamp);
    }
}

Related

  1. formatTimeStampMsec(long epochTime)
  2. formatTimestampTime(Timestamp ts, boolean colon)
  3. formatTimestampToIndex(java.sql.Timestamp timestamp)
  4. formatTimestampToLong(final String timestampStr)
  5. formatTimestampWithSlashes( java.sql.Timestamp tsZeitpunkt)
  6. formatToLong(String format)
  7. formatToString(long timestamp, String datePattern)
  8. formatValue(Object obj, boolean isboolean)
  9. friendlyTimestamp(Date date)