Here you can find the source of toCalendar(Date date)
Parameter | Description |
---|---|
date | the date to convert to a Calendar |
Parameter | Description |
---|---|
NullPointerException | if null is passed in |
public static Calendar toCalendar(Date date)
//package com.java2s; /******************************************************************************* * Copyright (c) 2011 MadRobot.// w ww .j a v a2 s . co m * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * Elton Kent - initial API and implementation ******************************************************************************/ import java.util.Calendar; import java.util.Date; public class Main { /** * Convert a Date into a Calendar object. * * @param date the date to convert to a Calendar * @return the created Calendar * @throws NullPointerException if null is passed in */ public static Calendar toCalendar(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c; } }