Here you can find the source of getCalendarFromDate(Date date)
Parameter | Description |
---|---|
date | - Date object. |
Parameter | Description |
---|---|
NullPointerException | if any of the parameters is null. |
public static Calendar getCalendarFromDate(Date date)
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main{ /**//from w ww . j ava 2 s .c o m * Get {@link Calendar} instance based on given {@link Date} object. * @param date -{@link Date} object. * @return -parsed {@link Calendar} object. * @throws NullPointerException if any of the parameters is null. */ public static Calendar getCalendarFromDate(Date date) { if (StringUtils.isNull(date)) { throw new NullPointerException("date cannot be null"); } Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar; } }