Here you can find the source of date2Calendar(Date date)
Parameter | Description |
---|---|
date | a date. |
public static Calendar date2Calendar(Date date)
//package com.java2s; /*//from www . j av a 2s. c o m * Copyright (c) 2015-2016 QuartzDesk.com. * Licensed under the MIT license (https://opensource.org/licenses/MIT). */ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { /** * Converts the specified {@link Date} to {@link Calendar} using the * system default time zone. * * @param date a date. * @return the calendar. */ public static Calendar date2Calendar(Date date) { return date2Calendar(date, TimeZone.getDefault()); } /** * Converts the specified {@link Date} to {@link Calendar} using the * specified time zone. * * @param date a date. * @param timeZone a time zone. * @return the calendar. */ public static Calendar date2Calendar(Date date, TimeZone timeZone) { if (date == null) return null; Calendar cal = new GregorianCalendar(timeZone); cal.setTime(date); return cal; } }