Java Calendar UTC getLocalCalendarFromUTC(Calendar utc)

Here you can find the source of getLocalCalendarFromUTC(Calendar utc)

Description

Get the equivalent UTC calendar to a local calendar

License

LGPL

Declaration

public static Calendar getLocalCalendarFromUTC(Calendar utc) 

Method Source Code

//package com.java2s;
/**//  w ww .  j  av  a  2s. 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;

public class Main {
    /**
     * Get the equivalent UTC calendar to a local calendar
     */
    public static Calendar getLocalCalendarFromUTC(Calendar utc) {
        Date valueDate = utc.getTime();
        Calendar c = Calendar.getInstance(); // this has the default timezone for the server
        c.setTime(valueDate);
        return c;
    }
}

Related

  1. getCalendarUTC()
  2. getCalendarUTC()
  3. getCalendarUTC(long timeMS)
  4. getUTCCalendar()
  5. getUtcCalendar()
  6. getUTCCalendar()
  7. getUtcCalendar()