Java Calendar Create createCalendar(long timeInMillis)

Here you can find the source of createCalendar(long timeInMillis)

Description

create Calendar

License

Open Source License

Declaration

public static Calendar createCalendar(long timeInMillis) 

Method Source Code


//package com.java2s;
/*/*from  w w w.  ja  va  2  s  .  co  m*/
 * Copyright 2009 Yodlee, Inc.  All Rights Reserved.  Your use of this code 
 * requires a license from Yodlee.  Any such license to this code is 
 * restricted to evaluation/illustrative purposes only. It is not intended 
 * for use in a production environment, and Yodlee disclaims all warranties 
 * and/or support obligations concerning this code, regardless of the terms 
 * of any other agreements between Yodlee and you."
 */

import java.util.Calendar;

public class Main {
    public static Calendar createCalendar(long timeInMillis) {

        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(timeInMillis);
        calendar.setMinimalDaysInFirstWeek(calculateMinimalDaysInFirstWeek(calendar));
        return calendar;
    }

    public static int calculateMinimalDaysInFirstWeek(Calendar calendar) {

        Calendar temp = (Calendar) calendar.clone();
        temp.set(Calendar.DAY_OF_YEAR, 1);
        int firstDayOfJan = temp.get(Calendar.DAY_OF_WEEK);
        return 8 - firstDayOfJan;
    }
}

Related

  1. createCalendar(final int year, final int month, final int dayOfMonth, final TimeZone timeZone)
  2. createCalendar(int year, int month, int date)
  3. createCalendar(int year, int month, int day)
  4. createCalendar(int year, int month, int day, int hour, int minute, int second, boolean ceiling)
  5. createCalendar(int year, int month, int dayOfMonth, int hourOfDay, int minute, int second)
  6. createCalendarFromParts(String[] parts)
  7. createCalendarInstance(final Locale locale)
  8. createCalendarMidnight(final Date date)
  9. createCalendarWith()