Java Date to Time getTime(Date date)

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

Description

Derives a Calendar object from a Date object

License

EUPL

Parameter

Parameter Description
date date object

Return

Calendar object

Declaration

public static Calendar getTime(Date date) 

Method Source Code

//package com.java2s;
/*/*from   w ww .  j  av  a2 s  .  c  o  m*/
 * Copyright 2013 Swedish E-identification Board (E-legitimationsn?mnden)
 *         
 *   Licensed under the EUPL, Version 1.1 or ? as soon they will be approved by the 
 *   European Commission - subsequent versions of the EUPL (the "Licence");
 *   You may not use this work except in compliance with the Licence. 
 *   You may obtain a copy of the Licence at:
 * 
 *   http://joinup.ec.europa.eu/software/page/eupl 
 * 
 *   Unless required by applicable law or agreed to in writing, software distributed 
 *   under the Licence is distributed on an "AS IS" basis,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 *   implied.
 *   See the Licence for the specific language governing permissions and limitations 
 *   under the Licence.
 */

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**
     * Derives a Calendar object from a millisecond time value
     * @param timeInMs milliseconds since Jan 1, 1970
     * @return Calendar object of the provided time
     */
    public static Calendar getTime(long timeInMs) {
        Calendar time = Calendar.getInstance();
        time.setTimeInMillis(timeInMs);
        return time;
    }

    /**
     * Derives a Calendar object from a Date object
     * @param date date object
     * @return Calendar object
     */
    public static Calendar getTime(Date date) {
        return getTime(date.getTime());
    }
}

Related

  1. getTime(Date date)
  2. getTime(Date date)
  3. getTime(Date date)
  4. getTime(Date date)
  5. getTime(Date date)
  6. getTime(Date date)
  7. getTime(Date date)
  8. getTime(Date date, boolean isEnd)
  9. getTime(Date date, String pattern, Locale locale)