Here you can find the source of getCalendarFromDate(final String dateTime)
getCalendarFromDate.
Parameter | Description |
---|---|
dateTime | a java.lang.String object. |
public static Calendar getCalendarFromDate(final String dateTime)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /**/*from w w w .j a va 2s. c o m*/ * <p>getCalendarFromDate.</p> * * @param dateTime a {@link java.lang.String} object. * @return a {@link java.util.Calendar} object. */ public static Calendar getCalendarFromDate(final String dateTime) { final Calendar cal = GregorianCalendar.getInstance(); final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { final Date date = sdf.parse(dateTime); cal.setTime(date); } catch (final ParseException e) { return null; } return cal; } }