Java Calendar Time convertTimeToLocalTimezone(Long pTime, Calendar pTargetCal)

Here you can find the source of convertTimeToLocalTimezone(Long pTime, Calendar pTargetCal)

Description

convert Time To Local Timezone

License

Apache License

Parameter

Parameter Description
pTZone a parameter
pTime a parameter
pTargetCal a parameter

Declaration

public static long convertTimeToLocalTimezone(Long pTime, Calendar pTargetCal) 

Method Source Code

//package com.java2s;
/**/*from w  w w. jav a 2  s  . c om*/
Copyright 2014 Jens Glufke
    
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    
http://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 * -----------------------------------------------------------------------
 *
 */

import java.util.Calendar;

import java.util.TimeZone;

public class Main {
    private final static Calendar gmtCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));

    /**
     *
     * @param pTZone
     * @param pTime
     * @param pTargetCal
     * @return
     *
     */
    public static long convertTimeToLocalTimezone(Long pTime, Calendar pTargetCal) {
        gmtCalendar.setTimeInMillis(pTime);

        pTargetCal.set(Calendar.YEAR, gmtCalendar.get(Calendar.YEAR));
        pTargetCal.set(Calendar.MONTH, gmtCalendar.get(Calendar.MONTH));
        pTargetCal.set(Calendar.DAY_OF_MONTH, gmtCalendar.get(Calendar.DAY_OF_MONTH));
        pTargetCal.set(Calendar.HOUR_OF_DAY, gmtCalendar.get(Calendar.HOUR_OF_DAY));
        pTargetCal.set(Calendar.MINUTE, gmtCalendar.get(Calendar.MINUTE));
        pTargetCal.set(Calendar.SECOND, gmtCalendar.get(Calendar.SECOND));
        pTargetCal.set(Calendar.MILLISECOND, gmtCalendar.get(Calendar.MILLISECOND));

        return pTargetCal.getTimeInMillis();
    }
}

Related

  1. clearTimeFields(final Calendar calendar)
  2. clearTimeFields(Set c)
  3. clearTimeFromCalendar(Calendar calendar)
  4. compareTimeOnly(Calendar cal1, Calendar cal2)
  5. convertCalendar(final Calendar calendar, final TimeZone timeZone)
  6. convertTimeToString(Calendar time)
  7. convertToActiveDirectoryTime(Calendar calendar)
  8. convertToCalendar(long adTimeValue)
  9. convertToTimeStpam(Calendar cal)