Java Calendar Create getCalendarForTime(final long timeInMilliseconds)

Here you can find the source of getCalendarForTime(final long timeInMilliseconds)

Description

Function to return a calendar object holding the UTC representation of the current time.

License

Open Source License

Parameter

Parameter Description
timeInMilliseconds the time in milliseconds from the Jan 1 1970 epoch that is to be used as the time to set the calendar to.

Return

the calendar object which represents the time that was passed in in UTC

Declaration

public static Calendar getCalendarForTime(final long timeInMilliseconds) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

import java.util.TimeZone;

public class Main {
    /**//w  w w  .ja va2s.c o m
     * Function to return a calendar object holding the UTC representation of the current time.
     * @param timeInMilliseconds
     *  the time in milliseconds from the Jan 1 1970 epoch that is to be used as the time to set 
     *  the calendar to.
     * @return
     *  the calendar object which represents the time that was passed in in UTC
     */
    public static Calendar getCalendarForTime(final long timeInMilliseconds) {
        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        calendar.setTimeInMillis(timeInMilliseconds);

        return calendar;
    }
}

Related

  1. getCalendarField(Date date, int calFieldId)
  2. getCalendarFieldName(int field)
  3. getCalendarFormYear(int year)
  4. getCalendarForNextRun( GregorianCalendar startTime, int targetDay, int targetHour)
  5. getCalendarForSchedule(Calendar cal)
  6. getCalendarFromDates(Date date, Date hourMinuteMillisseconds)
  7. getCalendarFromSystemTimeInMillis(long date)
  8. getCalendarGMT()
  9. getCalendarInstance()