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.Calendar;
import java.util.Locale;

public class Main {
    public static Calendar YYYYMMDDHHMMSSToCalendar(String str) {
        if (str != null) {
            Calendar cal = Calendar.getInstance();
            try {
                SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
                cal.setTime(FORMAT.parse(str));
                return cal;
            } catch (ParseException e) {
                return null;
            }
        }
        return null;
    }
}