Java Date to Calendar toCalendar(Date date)

Here you can find the source of toCalendar(Date date)

Description

Convert a Date into a Calendar object.

License

Open Source License

Parameter

Parameter Description
date the date to convert to a Calendar

Exception

Parameter Description
NullPointerException if null is passed in

Return

the created Calendar

Declaration

public static Calendar toCalendar(Date date) 

Method Source Code

//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;
    }
}

Related

  1. getCalendar(String dateString)
  2. newCalendar(Date date)
  3. toCalendar(Date date)
  4. toCalendar(Date date)
  5. toCalendar(Date date)
  6. toCalendar(Date date)
  7. toCalendar(Date dtime)
  8. toCalendar(Date value)
  9. toCalendar(final Date date)