Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**
     * Converts long to date
     * 
     * @param timeStamp
     *            date
     * @return date converts the date in required format
     */
    public static String convertToDate(long timeStamp) {
        if (timeStamp <= 0) {
            return "";
        }
        Date date = new Date(timeStamp);
        DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        String strDate = formatter.format(date);
        return strDate;
    }
}