Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.GregorianCalendar;

public class Main {
    public static GregorianCalendar getCalendarFromString(String theString) {
        String[] formatSplit = theString.split("T");
        String[] dateSplit = formatSplit[0].split("-");
        String[] timeSplit = formatSplit[1].split(":");
        int year = Integer.parseInt(dateSplit[0]);
        int month = Integer.parseInt(dateSplit[1]);
        int day = Integer.parseInt(dateSplit[2]);
        int hour = Integer.parseInt(timeSplit[0]);
        int minute = Integer.parseInt(timeSplit[1]);
        int second = Integer.parseInt(timeSplit[2]);
        GregorianCalendar result = new GregorianCalendar(year, month, day, hour, minute, second);
        return result;
    }
}