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

public class Main {
    public static Calendar timeStringToCalendar(String timeString) {
        try {
            SimpleDateFormat formatter = new SimpleDateFormat("HH:mm", Locale.CHINESE);
            Date date = formatter.parse(timeString);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            return calendar;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}