Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static String getDateTime(Date date, String strFormat) {
        Date currentDate = date;
        if (strFormat == null) {
            strFormat = "yyyyMMddHHmmss";
        }
        DateFormat dateFormat = new SimpleDateFormat(strFormat);
        if (currentDate == null) {
            currentDate = new Date();
        }
        return dateFormat.format(currentDate);
    }
}