Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;

public class Main {
    private static SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.ITALIAN);

    public static GregorianCalendar getCalFromString(String data) {
        dateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.ITALIAN);
        try {
            Date dateTime = dateFormat.parse(data);
            GregorianCalendar gregCalendar = new GregorianCalendar();
            gregCalendar.setTime(dateTime);
            return gregCalendar;
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }
}