Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static Date String2Date(String date) {
        Date DateTime = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINESE);
        try {
            DateTime = sdf.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return DateTime;
    }
}