Java Timestamp Format formatTimestamp(long timestamp)

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

Description

format Timestamp

License

Open Source License

Parameter

Parameter Description
timestamp Epoch time

Return

The timestamp formatted as 'HH:mm' or null if the timestamp is <= 0.

Declaration

public static String formatTimestamp(long timestamp) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**//from  w  w  w  .j  a  v a2 s  . com
     * @param timestamp Epoch time
     * @return The timestamp formatted as 'HH:mm' or <code>null</code> if the timestamp is <= 0.
     */
    public static String formatTimestamp(long timestamp) {
        if (timestamp <= 0)
            return null;
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
        return (sdf.format(new Date(timestamp)));
    }
}

Related

  1. formatTimestamp(final Date date)
  2. formatTimestamp(final Long timestamp)
  3. formatTimeStamp(long epochTime)
  4. formatTimestamp(Long mills)
  5. formatTimestamp(long timestamp)
  6. formatTimestamp(long timestamp)
  7. formatTimestamp(long timestamp)
  8. formatTimestamp(long timestamp)
  9. formatTimestamp(long timestamp)