Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 *   Copyright (c) 2014-2015 Luis M. Gallardo D.
 *   All rights reserved. This program and the accompanying materials
 *   are made available under the terms of the GNU Lesser General Public License v3.0
 *   which accompanies this distribution, and is available at
 *   http://www.gnu.org/licenses/lgpl.html
 *
 */

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

public class Main {
    public static String timestampToDate(String timestamp) {

        Long unixtimestamp = Long.parseLong(timestamp);

        //        Log.d("Debug", "TimeStamp: " + unixtimestamp);

        if ("4294967295".equals(unixtimestamp)) {
            return "";
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm");
        Date date = new Date(unixtimestamp * 1000);
        return new SimpleDateFormat("dd/MM/yyyy - HH:mm").format(date);

    }
}