Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

public class Main {

    public static String getDateStr(long milliseconds) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd E HH:mm:ss");
        return df.format(new Date(milliseconds));
    }

    public static String getDateStr(long milliseconds, String format) {
        SimpleDateFormat df = new SimpleDateFormat(format);
        return df.format(new Date(milliseconds));
    }

    public static String getDateStr(Date date, String format) {
        if (date == null) {
            return "";
        }
        return getDateStr(date.getTime(), format);
    }
}