Java Long Number to Timestamp timestamp2DateTime(long t)

Here you can find the source of timestamp2DateTime(long t)

Description

convert a Unix timestamp to date time string

License

Open Source License

Parameter

Parameter Description
t Unix timestamp (milliseconds since 1/1/1970 eg System.currentTimeMillis();

Return

time formatted as yyyy-mm-dd hh:mm:ss

Declaration

public static String timestamp2DateTime(long t) 

Method Source Code

//package com.java2s;
/*/*from ww w .  j  ava 2s  . c  o  m*/
 * Copyright (C) 2012 Joseph Areeda <joseph.areeda at ligo.org>
 *
 * This program 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.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.text.SimpleDateFormat;

public class Main {
    /**
     * convert a Unix timestamp to date time string
     *
     * @param t Unix timestamp (milliseconds since 1/1/1970 eg System.currentTimeMillis();
     * @return time formatted as yyyy-mm-dd hh:mm:ss
     */
    public static String timestamp2DateTime(long t) {
        String ret;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        ret = sdf.format(t);
        return ret;

    }
}

Related

  1. printTimestamp(Long c)
  2. reverseTimestampToNormalTime(long timestamp)
  3. timestamp(long time)
  4. timestamp2DataTime(long timestamp)
  5. timestamp2Date(long timestamp, String timezone)
  6. timestampToHumanDateAndTime(long timestamp)
  7. timestampToString(long micros)
  8. timestampToString(long time)
  9. timestampToString(long timestamp)