Java Timestamp Format format(long timestamp)

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

Description

format

License

Apache License

Declaration

public static String format(long timestamp) 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Date;

import java.util.TimeZone;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class Main {
    private static final BlockingQueue<SimpleDateFormat> formats = new ArrayBlockingQueue<SimpleDateFormat>(20);

    public static String format(long timestamp) {
        SimpleDateFormat format = formats.poll();

        if (format == null) {
            format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            format.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        }/*from ww w  .j a v  a  2  s.  c  o  m*/

        try {
            return format.format(new Date(timestamp));
        } finally {
            if (formats.remainingCapacity() > 0) {
                formats.offer(format);
            }
        }
    }
}

Related

  1. format(Date timestamp)
  2. format(Date timestamp, String format)
  3. Format(DateFormat format, Timestamp time)
  4. format(final Date date)
  5. format(final long unixTimeStamp)
  6. format(long timeStamp)
  7. format(Timestamp time)
  8. format2AdwordsTimestamp(Date date)
  9. format8chars(long timestamp)