Java Hour getGMTHour(int localHour)

Here you can find the source of getGMTHour(int localHour)

Description

get GMT Hour

License

Open Source License

Declaration

static int getGMTHour(int localHour) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008,2011 Peter Stibrany
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from   w  w w.  j  a  v  a2  s . c  om*/
 *    Peter Stibrany (pstibrany@gmail.com) - initial API and implementation
 *******************************************************************************/

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

public class Main {
    static int getGMTHour(int localHour) {
        Calendar c = Calendar.getInstance();
        c.clear();
        c.set(Calendar.HOUR_OF_DAY, localHour);

        Date t = c.getTime();

        c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        c.clear();
        c.setTime(t);

        return c.get(Calendar.HOUR_OF_DAY);
    }
}

Related

  1. getCurrentHour()
  2. getCurrentHours()
  3. getCurrHour()
  4. getDelay(int hour, int min)
  5. getDelayToNextHour(int amount, boolean skipNext)
  6. getHexString(byte[] raw)
  7. getHour()
  8. getHour()
  9. getHour()