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

public class Main {
    public static Calendar getDateFromString(String string, String format) {
        Calendar calendar = null;

        SimpleDateFormat form = new SimpleDateFormat(format, Locale.US);
        Date date = null;

        try {
            date = form.parse(string);

            calendar = Calendar.getInstance();
            calendar.setTime(date);
        } catch (java.text.ParseException e) {
        }

        return calendar;
    }
}