Java BigDecimal getLocalHourMinute(BigDecimal gmtHour)

Here you can find the source of getLocalHourMinute(BigDecimal gmtHour)

Description

get Local Hour Minute

License

Open Source License

Declaration

static int getLocalHourMinute(BigDecimal gmtHour) 

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 o  m*/
 *    Peter Stibrany (pstibrany@gmail.com) - initial API and implementation
 *******************************************************************************/

import java.math.BigDecimal;
import java.math.RoundingMode;

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

public class Main {
    static int getLocalHourMinute(BigDecimal gmtHour) {
        Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        c.clear();

        int hour = gmtHour.intValue();

        c.set(Calendar.HOUR_OF_DAY, hour);
        Date t = c.getTime();

        c = Calendar.getInstance();
        c.setTime(t);

        int localHour = c.get(Calendar.HOUR_OF_DAY);

        int minuteV = gmtHour.subtract(gmtHour.setScale(0, RoundingMode.FLOOR)).multiply(new BigDecimal("60"))
                .intValue();

        return localHour * 100 + minuteV;
    }
}

Related

  1. getIntLength(BigDecimal val)
  2. getIntValue(BigDecimal b)
  3. getLength(BigDecimal v)
  4. getLet(BigDecimal nl, BigDecimal el)
  5. getLetJp(BigDecimal nl)
  6. getMaxBigDecimal(@Nonnull final BigDecimal aValue, @Nonnull final BigDecimal... aValues)
  7. getMaxBigDecimal(int precision, int scale)
  8. getMaxPrecision(BigDecimal... decimals)
  9. getMean(final BigDecimal... vals)