Here you can find the source of getCalendarObject(String value, boolean hasMills)
private static Calendar getCalendarObject(String value, boolean hasMills)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { protected static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); protected static final SimpleDateFormat SIMPLE_DATE_FORMAT_MILLS = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS"); private static Calendar getCalendarObject(String value, boolean hasMills) { try {// w w w .j av a 2 s . co m Calendar calendar = Calendar.getInstance(); if (hasMills) { calendar.setTime(SIMPLE_DATE_FORMAT_MILLS.parse(value)); } else { calendar.setTime(SIMPLE_DATE_FORMAT.parse(value)); } return calendar; } catch (ParseException e) { } return null; } }