Here you can find the source of timestamp2DateTime(long t)
Parameter | Description |
---|---|
t | Unix timestamp (milliseconds since 1/1/1970 eg System.currentTimeMillis(); |
public static String timestamp2DateTime(long t)
//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; } }