Java Calendar UTC getUTCCalendarFromLocalDate(Date date)

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

Description

Convert a local date time to a UTC calendar

License

LGPL

Declaration

public static Calendar getUTCCalendarFromLocalDate(Date date) 

Method Source Code

//package com.java2s;
/**//  ww  w .j a  v a2s  . co m
 *
 * Magnolia and its source-code is licensed under the LGPL.
 * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
 * When copying, adapting, or redistributing this document in keeping with the guidelines above,
 * you are required to provide proper attribution to obinary.
 * If you reproduce or distribute the document without making any substantive modifications to its content,
 * please use the following attribution line:
 *
 * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
 *
 */

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

public class Main {
    public static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("UTC");

    /**
     * Convert a local date time to a UTC calendar
     */
    public static Calendar getUTCCalendarFromLocalDate(Date date) {
        Calendar instance = Calendar.getInstance(UTC_TIME_ZONE);
        instance.setTimeInMillis(date.getTime());
        return instance;
    }
}

Related

  1. getUTCCalendar()
  2. getUtcCalendar()
  3. getUTCCalendar()
  4. getUTCCalendar()
  5. getUTCCalendar(Date date)
  6. getUTCCalendarInstance()
  7. getUtcMillisFromEpoch(Calendar calendar)
  8. subtractFromUTCMilliSeconds(int calendarTime, int actualValue)