Here you can find the source of getCalendar(String time, char sep, boolean isStart)
public static Calendar getCalendar(String time, char sep, boolean isStart)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static Calendar getCalendar(String time, char sep, boolean isStart) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, isStart ? 0 : 23); cal.set(Calendar.MINUTE, isStart ? 0 : 59); cal.set(Calendar.SECOND, isStart ? 0 : 59); cal.set(Calendar.MILLISECOND, isStart ? 0 : 999); try {/* w w w . j a v a 2s. co m*/ int idx = time.indexOf(sep); if (idx != -1) { cal.set(Calendar.YEAR, Integer.parseInt(time.substring(0, idx))); time = time.substring(idx + 1); idx = time.indexOf(sep); if (idx != -1) { cal.set(Calendar.MONTH, Integer.parseInt(time.substring(0, idx)) - 1); cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(time.substring(idx + 1))); } } } catch (Exception e) { e.printStackTrace(); } return cal; } }