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 final String DEFAUL_PARSE = "yyyy-MM-dd HH:mm:ss";

    public static String getCurrentDateStr() {
        return getParseDateToStr(getCurrentDate(), DEFAUL_PARSE);
    }

    public static String getParseDateToStr(Date date) {
        return getParseDateToStr(date, DEFAUL_PARSE);
    }

    public static String getParseDateToStr(Date date, String parsePattern) {
        Locale locale = Locale.CHINA;
        SimpleDateFormat dataformat = new SimpleDateFormat(parsePattern, locale);
        return dataformat.format(date);
    }

    public static Date getCurrentDate() {
        return new Date(System.currentTimeMillis());
    }
}