转换为Calendar对象

@param millis 时间戳
@return Calendar对象
766792
public static Calendar calendar(long millis) {
		final Calendar cal = Calendar.getInstance();
		cal.setTimeInMillis(millis);
		return cal;
	}
928738
public Calendar getStart() {
		Calendar cal = Calendar.getInstance();
		cal.setTimeInMillis(start);
		return cal;
	}
661730
public static Calendar toCalendar(final Instant self) {
        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
        cal.setTime(toDate(self));
        return cal;
    }
574610
private Calendar getCalendar(String iso8601Date) throws
      InvalidDateException
  {
    // YYYY-MM-DDThh:mm:ss.sTZD
    StringTokenizer st = new StringTokenizer(iso8601Date, "-T:.+Z", true);
    if (!st.hasMoreTokens())
    {
      throw new InvalidDateException("Empty Date");
    }
    Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
    calendar.clear();
    try
    {
      // Year
      if (st.hasMoreTokens())
      {
        int year = Integer.parseInt(st.nextToken());
        calendar.set(Calendar.YEAR, year);
      }
      else
      {
        return calendar;
      }
      // Month
      if (checkValueAndNext(st, "-"))
      {
        int month = Integer.parseInt(st.nextToken()) - 1;
        calendar.set(Calendar.MONTH, month);
      }
      else
      {
        return calendar;
      }
      // Day
      if (checkValueAndNext(st, "-"))
      {
        int day = Integer.parseInt(st.nextToken());
        calendar.set(Calendar.DAY_OF_MONTH, day);
      }
      else
      {
        return calendar;
      }
      // Hour
      if (checkValueAndNext(st, "T"))
      {
        int hour = Integer.parseInt(st.nextToken());
        calendar.set(Calendar.HOUR_OF_DAY, hour);
      }
      else
      {
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar;
      }
      // Minutes
      if (checkValueAndNext(st, ":"))
      {
        int minutes = Integer.parseInt(st.nextToken());
        calendar.set(Calendar.MINUTE, minutes);
      }
      else
      {
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar;
      }
      if (!st.hasMoreTokens())
      {
        return calendar;
      }
      // Not mandatory now
      // Seconds
      String tok = st.nextToken();
      if (tok.equals(":"))
      { // seconds
        if (st.hasMoreTokens())
        {
          int secondes = Integer.parseInt(st.nextToken());
          calendar.set(Calendar.SECOND, secondes);
          if (!st.hasMoreTokens())
          {
            return calendar;
          }
          // decimal fraction of a second
          tok = st.nextToken();
          if (tok.equals("."))
          {
            String nt = st.nextToken();
            while (nt.length() < 3)
            {
              nt += "0";
            }
            if (nt.length() > 3)
            {
              // check the other part from the decimal fraction to be formed only from digits
              for (int i = 3; i < nt.length(); i++)
              {
                if (!Character.isDigit(nt.charAt(i)))
                {
                  throw new InvalidDateException("Invalid digit in the decimal fraction of a second: " + nt.charAt(i));
                }
              }
            }
            nt = nt.substring(0, 3); //Cut trailing chars..
            int millisec = Integer.parseInt(nt);
            calendar.set(Calendar.MILLISECOND, millisec);
            if (!st.hasMoreTokens())
            {
              return calendar;
            }
            tok = st.nextToken();
          }
          else
          {
            calendar.set(Calendar.MILLISECOND, 0);
          }
        }
        else
        {
          throw new InvalidDateException("No secondes specified");
        }
      }
      else
      {
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
      }
      // Time zone
      if (!tok.equals("Z"))
      { // UTC
        if (!(tok.equals("+") || tok.equals("-")))
        {
          throw new InvalidDateException("only Z, + or - allowed");
        }
        boolean plus = tok.equals("+");
        if (!st.hasMoreTokens())
        {
          throw new InvalidDateException("Missing hour field");
        }
        int tzhour = Integer.parseInt(st.nextToken());
        int tzmin;
        if (checkValueAndNext(st, ":"))
        {
          tzmin = Integer.parseInt(st.nextToken());
        }
        else
        {
          throw new InvalidDateException("Missing minute field");
        }
        if (plus)
        {
          calendar.add(Calendar.HOUR, -tzhour);
          calendar.add(Calendar.MINUTE, -tzmin);
        }
        else
        {
          calendar.add(Calendar.HOUR, tzhour);
          calendar.add(Calendar.MINUTE, tzmin);
        }
      }
      else
      {
        if (st.hasMoreTokens())
        {
          throw new InvalidDateException("Unexpected field at the end of the date field: " + st.nextToken());
        }
      }
    }
    catch (NumberFormatException ex)
    {
      throw new InvalidDateException("[" + ex.getMessage() + "] is not an integer");
    }
    return calendar;
  }
635335
private static Calendar getCalendar(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar;
    }
1125877
public int getShowMonth() {
        Calendar cal = Calendar.getInstance();
        cal.setTime(getDate());
        return cal.get(Calendar.MONDAY);
    }
1121888
@Override
    public <B extends Appendable> B format(final long millis, final B buf) {
        final Calendar c = newCalendar();
        c.setTimeInMillis(millis);
        return applyRules(c, buf);
    }
1028651
public static Calendar getInstance()
    {
        return createCalendar(TimeZone.getDefault(), Locale.getDefault(Locale.Category.FORMAT));
    }
1100580
public Calendar getCalendar(final Date min, final Date max) {
		long millis = getLong(min.getTime(), max.getTime());
		return createCalendar(millis);
	}
1110653
public static Calendar startOfMonth(Calendar origin) {
        Calendar cal = (Calendar) origin.clone();
        cal.set(Calendar.MILLISECOND, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.DAY_OF_MONTH, 1);
        return cal;
    }
305189
public static long millis(final String time, final String timeUnit) {
      return TIMEUNITS.get(timeUnit).toMillis(Long.parseLong(time));
   }
478089
public static Calendar popCalendar(Date date)
   {
      Calendar calendar = popCalendar();
      calendar.setTime(date);
      return calendar;
   }
43886
public Calendar calendarValue()
    {
        Calendar cal = new GregorianCalendar(_Private_Utils.UTC);

        long millis = getMillis();
        Integer offset = _offset;
        if (offset != null && offset != 0)
        {
            int offsetMillis = offset * 60 * 1000;
            millis += offsetMillis;
            cal.setTimeInMillis(millis);                // Resets the offset!
            cal.set(Calendar.ZONE_OFFSET, offsetMillis);
        }
        else
        {
            cal.setTimeInMillis(millis);
        }

        switch (_precision) {
            case YEAR:
                cal.clear(Calendar.MONTH);
            case MONTH:
                cal.clear(Calendar.DAY_OF_MONTH);
            case DAY:
                cal.clear(Calendar.HOUR_OF_DAY);
                cal.clear(Calendar.MINUTE);
            case MINUTE:
                cal.clear(Calendar.SECOND);
                cal.clear(Calendar.MILLISECOND);
            case SECOND:
                if (_fraction == null) {
                    cal.clear(Calendar.MILLISECOND);
                }
        }

        return cal;
    }
1361641
public static Duration fromMillis(long milliseconds) {
		Duration.Builder builder = builder();

		if (milliseconds < 0) {
			builder.prior(true);
			milliseconds *= -1;
		}

		int seconds = (int) (milliseconds / 1000);

		Integer weeks = seconds / (60 * 60 * 24 * 7);
		if (weeks > 0) {
			builder.weeks(weeks);
		}
		seconds %= 60 * 60 * 24 * 7;

		Integer days = seconds / (60 * 60 * 24);
		if (days > 0) {
			builder.days(days);
		}
		seconds %= 60 * 60 * 24;

		Integer hours = seconds / (60 * 60);
		if (hours > 0) {
			builder.hours(hours);
		}
		seconds %= 60 * 60;

		Integer minutes = seconds / (60);
		if (minutes > 0) {
			builder.minutes(minutes);
		}
		seconds %= 60;

		if (seconds > 0) {
			builder.seconds(seconds);
		}

		return builder.build();
	}
1149188
private static Calendar dateToCalendar(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		return cal;
	}
45384
public static Calendar getDateCeil(Date date) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(date);
        return new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
    }
737867
public static Calendar startOfHour(Calendar origin) {
        Calendar cal = (Calendar) origin.clone();
        cal.set(Calendar.MILLISECOND, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        return cal;
    }