Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.text.TextUtils;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static String getFormatTime(String format, long time) {
        if (TextUtils.isEmpty(format))
            return null;

        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        Date date = new Date(time);
        return dateFormat.format(date);
    }

    public static String getFormatTime(String format, String time) {
        if (TextUtils.isEmpty(format) || TextUtils.isEmpty(time))
            return null;

        return getFormatTime(format, Long.valueOf(time));
    }
}