Java Long Number to Timestamp timestampToHumanDateAndTime(long timestamp)

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

Description

Convert a timestamp to a humanly readable date and time.

License

Open Source License

Parameter

Parameter Description
timestamp - date and time in timestamp format

Return

m_dateAndTime - a humanly readable format for the date and time input

Declaration

public static String timestampToHumanDateAndTime(long timestamp) 

Method Source Code

//package com.java2s;
/*/*from w w  w .j  av a2 s  .c  om*/
    
 Copyright IBM Corp. 2012, 2016
 This file is part of Anomaly Detection Engine for Linux Logs (ADE).

 ADE is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 ADE is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with ADE.  If not, see <http://www.gnu.org/licenses/>.
    
 */

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

import java.util.Date;

import java.util.Locale;

public class Main {
    private static final ThreadLocal<DateFormat> m_dateAndTime = new ThreadLocal<DateFormat>() {
        @Override
        protected DateFormat initialValue() {
            return new SimpleDateFormat("d MMM yyyy HH:mm:ss", new Locale(
                    "en", "US"));
        }
    };

    /**
     * Convert a timestamp to a humanly readable date and time.
     * 
     * @param timestamp - date and time in timestamp format
     * @return m_dateAndTime - a humanly readable format for the date and time input
     */
    public static String timestampToHumanDateAndTime(long timestamp) {
        return m_dateAndTime.get().format(new Date(timestamp));
    }
}

Related

  1. reverseTimestampToNormalTime(long timestamp)
  2. timestamp(long time)
  3. timestamp2DataTime(long timestamp)
  4. timestamp2Date(long timestamp, String timezone)
  5. timestamp2DateTime(long t)
  6. timestampToString(long micros)
  7. timestampToString(long time)
  8. timestampToString(long timestamp)
  9. timeString(long timestamp)