Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.Date;
import java.util.Locale;

public class Main {

    public static String formatDate(String format, Long time) {
        return formatDate(new SimpleDateFormat(format, Locale.CHINA), time);
    }

    public static String formatDate(SimpleDateFormat format, Long time) {
        if (null == time || time <= 0) {
            return "";
        }
        return format.format(new Date(String.valueOf(time).length() == 13 ? time : time * 1000));
    }
}