Java Calendar Millisecond toCalendar(final long millis)

Here you can find the source of toCalendar(final long millis)

Description

Creates an instance of java.util.Calendar from the given time in milliseconds.

License

Open Source License

Parameter

Parameter Description
millis A given time corresponding to the number of milliseconds since January 1, 1970, 00:00:00 GMT

Return

Converted Calendar object.

Declaration

public static Calendar toCalendar(final long millis) 

Method Source Code


//package com.java2s;
import java.util.Calendar;
import java.util.Date;

public class Main {
    /**/*www .j  av  a 2s. c  om*/
     * Converts an instance of {@link java.util.Date} object to {@link java.util.Calendar}.
     *
     * @param date
     *            date object to convert.
     * @return Converted <code>Calendar</code> object.
     */
    public static Calendar toCalendar(final Date date) {
        final Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar;
    }

    /**
     * Creates an instance of {@link java.util.Calendar} from the given time in milliseconds.
     * <p>
     * The input milliseconds value represents the specified number of milliseconds since the standard base time known
     * as "the epoch", namely January 1, 1970, 00:00:00 GMT.
     *
     * @param millis
     *            A given time corresponding to the number of milliseconds since January 1, 1970, 00:00:00 GMT
     * @return Converted <code>Calendar</code> object.
     */
    public static Calendar toCalendar(final long millis) {
        final Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(millis);
        return calendar;
    }
}

Related

  1. newCalendar(long timeInMillis)
  2. setCalendar(Calendar calendar, int wholeDays, int millisecondsInDay, boolean use1904windowing)
  3. setCalendar(Calendar calendar, int wholeDays, int millisecondsInDay, boolean use1904windowing, boolean roundSeconds)
  4. setCalendarTime(Calendar inCalendar, int hr, int min, int sec, int milliSec)
  5. setTimeInMillis(Calendar _calendar, long _timemillis)
  6. toCalendar(long millis)
  7. toStringDateTimeMillisecond(Calendar calendar)
  8. translateToMilliseconds(Calendar calendar)